In my python idle 3.7 the "else" statement is not working?Please help me. | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 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 Antworten
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