+ 1

In my python idle 3.7 the "else" statement is not working?Please help me.

13th May 2019, 11:18 AM
Amisha
Amisha - avatar
8 Réponses
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.
13th May 2019, 11:28 AM
Théophile
Théophile - avatar
+ 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
13th May 2019, 11:25 AM
Amisha
Amisha - avatar
+ 1
Thanks
13th May 2019, 11:30 AM
Amisha
Amisha - avatar
+ 1
Hey when used pass in the code, it still shows error . Please help me
14th May 2019, 10:43 AM
Amisha
Amisha - avatar
0
Can you show us the code you wrote in IDLE, please? So that we can help you...
13th May 2019, 11:22 AM
Théophile
Théophile - avatar
0
You're welcome!
13th May 2019, 11:32 AM
Théophile
Théophile - avatar
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?😢😢😢
14th May 2019, 11:14 AM
Amisha
Amisha - avatar
0
That's the same after an elif statement : elif user_input == "add": pass
14th May 2019, 12:00 PM
Théophile
Théophile - avatar