Python - How to break while loop after empty value in a int turning input? [duplicate]
问题 This question already has answers here : Asking the user for input until they give a valid response (20 answers) Closed 3 years ago . I want to make the while loop break when empty input is typed. I know that the error is due to the int function because it cant turn to integer an empty input but how can i do what i'm trying to write? while True: numb = int(input("number")) if numb % 2 == 0: print("this number is even") elif numb % 2 != 0: print("this number is odd") elif numb == '': break 回答1