Oct-21-2016, 03:15 PM
First some house cleaning.
You don't need line 4. Lines 6 & 7 can be written as
Usually you can do this with the "try/except" statement, for example:
You don't need line 4. Lines 6 & 7 can be written as
questionmark = "?" haddaway = "What is love?"
Quote:How can I let python check for the intended input in a practical manner?
Usually you can do this with the "try/except" statement, for example:
answer = ["yes", "no"] while True: try: response = input("Enter your response: ") if response in answer: print("Correct response") break else: print("Wrong response, try again") continue except ValueError as err: print("There was an error {}".format(err)) print("Done")
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition