How to catch empty user input using a try and except in python? [closed]
I am trying to figure out how I can catch empty user input using a try and except. If you had this for example: try: #user input here. integer input except ValueError: #print statement saying empty string. Although I also need to catch another value error to make sure they entered an integer and not a character or string how could I use an if and elif setup in order to figure out if it is an empty string or str instead of int If you literally want to raise an exception only on the empty string, you'll need to do that manually: try: user_input = input() # raw_input in Python 2.x if not user