0

Else is not working..... Python shows syntax error

2nd Aug 2016, 1:42 PM
indresh mahor
indresh mahor - avatar
10 Respuestas
+ 5
@indresh remove indentation from else. it's not the same block of code.
3rd Aug 2016, 11:38 AM
Henrique Santana
Henrique Santana - avatar
+ 5
yes, if you remove the indentation it should work. same for elif. Also, you may want to add some code after else to tell it what to do when it runs. so, let's apply this to your example: x = 4 if x == 5: print("yes") elif x == 3: print("yep") else: print("no")
3rd Aug 2016, 11:58 AM
Jasper Ro
Jasper Ro - avatar
+ 1
could you share the code you used?
2nd Aug 2016, 5:28 PM
Jasper Ro
Jasper Ro - avatar
0
X=4 If x==5: Print("yes") Else: After this when I press enter python shows syntax error
3rd Aug 2016, 3:44 AM
indresh mahor
indresh mahor - avatar
0
And elif also doesn't work
3rd Aug 2016, 3:45 AM
indresh mahor
indresh mahor - avatar
0
in first lune x should be smaller n e also should be smaller in else
6th Aug 2016, 12:53 PM
Rahul Kadav
Rahul Kadav - avatar
0
X and x are different. Python is case sensitive.
8th Aug 2016, 10:33 PM
Вассесуарий Пупочкин
Вассесуарий Пупочкин - avatar
0
indresh, Python is case sensitive. You defined X, not x
15th Aug 2016, 2:52 AM
Suit A
Suit A - avatar
0
i got The same issue
23rd Oct 2016, 1:38 AM
Alexis Santana gonzalez
Alexis Santana gonzalez - avatar
- 1
Probably you're missing the colon at the end. But share your code with us.
3rd Aug 2016, 2:26 AM
Henrique Santana
Henrique Santana - avatar