+ 1
In my python idle 3.7 the "else" statement is not working?Please help me.
8 Answers
0
I see.
Write :
x = 4
if x==6:
print("yes")
else:
pass
If you write nothing in an else statement, then it will show you an error. 'pass' is used when you want to write nothing in a block : It does nothing.
+ 2
The code which I wrote is here:
x=4
if x == 6:
print("Yes")
else:
After pressing Enter it shows this:
SyntaxError: Invalid syntax
+ 1
Thanks
+ 1
Hey when used pass in the code, it still shows error . Please help me
0
Can you show us the code you wrote in IDLE, please? So that we can help you...
0
You're welcome!
0
while True:
print("Options:")
print("Enter 'add' to add two numbers")
print("Enter 'subtract' to subtract two numbers")
print("Enter 'multiply' to multiply two numbers")
print("Enter 'divide' to divide two numbers")
print("Enter 'quit' to end the program")
user_input = input(": ")
if user_input == "quit":
break
elif user_input == "add":
( after pressing enter in my computer it shows invalid syntax)
The else statement is not working. I have tried so many time but it just gives an error. What should I do?đąđąđą
0
That's the same after an elif statement :
elif user_input == "add":
pass