I am trying to type the following into the IDLE:
userInput = input('Enter 1 or 2: ')
if userInput == "1": print ("Hello World") print (“How
are you?”) elif userInput == "2": print ("Python
Rocks!") print (“I love Python”) else:
print ("You did not enter a valid number")
However, the moment after I typed the first line and pressed Enter, the program runs and asks me to Enter 1 or 2.
How can I write the full set of instructions before running?
Thanks
I've figured it out. It should be as follows:
userInput = input('Enter 1 or 2: ')
if userInput == "1":
print ("Hello World")
print ("How are you?")
elif userInput == "2":
print ("Python Rocks!")
print ("I love Python")
else: print ("You did not enter a valid number")
It seems I wrote it originally in the Shell and NOT the IDLE.