I'm trying to using Try, Except to check an input() to make sure it's not blank.
I'm using it at a different part of my program to check a float(input()) and it catches it if someone leaves it blank or enters a string, but I assume that's because it's checking the type to make sure it's a number, and a string isn't a number and leaving it blank isn't a number.
However, for just the input(), I need to check to make sure it's not a number and to check to make sure it isn't blank, but since it's just a plain-ol' input, it accepts anything thrown into it, so it doesn't raise an exception.
How can I check to make sure a string is entered?
This is my function:
def checkInput(prompt): result = None while result == None: try: result = input(prompt) return result except: print("Please insert an appropriate value!")