code: def get_input(input_func, input_str):
      
      val = input_func("Please enter your {0}: ".format(input_str))
      while not val or not len(val.strip()):
          val = input_func("You didn't enter a valid {0}, please try again: ".format(input_str))
      return val
docs: Get input from the user given an input function and an input string