+ 1

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

11th Jul 2018, 3:19 PM
Bhavya Pawar
Bhavya Pawar - avatar
8 ответов
+ 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