Whenever i give else command it shows "SyntaxError: invalid syntax" why? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

Whenever i give else command it shows "SyntaxError: invalid syntax" why?

11th Jul 2018, 3:19 PM
Bhavya Pawar
Bhavya Pawar - avatar
8 Antworten
+ 3
You have to indent your code like if True: print(True) else: print(False)
11th Jul 2018, 3:40 PM
Mert Yaz─▒c─▒
Mert Yaz─▒c─▒ - avatar
+ 2
code?
11th Jul 2018, 3:33 PM
Mert Yaz─▒c─▒
Mert Yaz─▒c─▒ - avatar
+ 1
Num=5 if num >5: print("true" ) else: After this it shows erroe
11th Jul 2018, 3:38 PM
Bhavya Pawar
Bhavya Pawar - avatar
+ 1
But when we want to nest it
11th Jul 2018, 3:42 PM
Bhavya Pawar
Bhavya Pawar - avatar
+ 1
And thanks
11th Jul 2018, 3:43 PM
Bhavya Pawar
Bhavya Pawar - avatar
+ 1
Thanks it works
11th Jul 2018, 3:47 PM
Bhavya Pawar
Bhavya Pawar - avatar
+ 1
Ok thanks
11th Jul 2018, 4:00 PM
Bhavya Pawar
Bhavya Pawar - avatar
0
When you want to nest, you indent even further. if True: print("1st") if True: print("2nd")
11th Jul 2018, 3:59 PM
Matthias
Matthias - avatar