How do I use ‘elif’ and ‘else’ statements in this case? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do I use ‘elif’ and ‘else’ statements in this case?

What is wrong with my code? Produces SyntaxError in line 7 but other lines may also be incorrect: level = 5 highest_level = 50 print(level == highest_level) if highest_level: 50 print("wow, you're level 50 alright!") elif highest_level == > 50 print ("still gotta long way to go shawty!") else: print("ok ok okayyyy ok")

24th Nov 2021, 3:55 PM
Saman Salih
Saman Salih - avatar
4 Answers
+ 11
Saman Salih , why not start learning in a python tutorial? it will shorten your way to a required knowledge level. happy coding!
24th Nov 2021, 4:12 PM
Lothar
Lothar - avatar
+ 4
On line 4 do you mean: if highest_level=50: On line 5 you should add spaces before the print statement if you only want to print the text if highest_level is equal to 50. On line 7 add a colon : after 50. And do you want to see if it is equal or major you cannot combine both signs == or > or >= (major or equal sign). So I think it should be: level = 5 highest_level =50 print(level==highest_level) if highest_level ==50: print("wow...") elif highest_level >= 50: print("still...") else: print("ok...") Hope this helps.
24th Nov 2021, 4:06 PM
Lebi
+ 1
Take another look at these topics: - indentation - comparison operators
24th Nov 2021, 6:32 PM
Simon Sauter
Simon Sauter - avatar
0
Lebi in the if statement you have to use the comparison operator "==", not the assignment operator "=".
24th Nov 2021, 6:33 PM
Simon Sauter
Simon Sauter - avatar