Invalid Sintax | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Invalid Sintax

Someone can help me ? I don't know Why python get this error https://code.sololearn.com/cdW8azX7NP77/?ref=app

25th Apr 2021, 12:38 AM
Brahian Suárez
Brahian Suárez - avatar
7 Answers
+ 6
First problem: line 4 should begin elif score not elif grade Second problem: If you are testing more than one condition, you have to phrase it like this: if x > y and x < z not like this: if x > y and < z 🙂
25th Apr 2021, 1:02 AM
David Ashton
David Ashton - avatar
+ 4
Instead of doing; x > y and x < z Or a similar 'and' operation using the same comparison value on each side of the 'and', you can chain them together like; y < x < z and achieve the same result. def exam_grade(score): if 100 >= score >= 95: grade = "Top Score" elif 94 >= score >= 60: grade = "Pass" else: grade = "Fail" return grade
25th Apr 2021, 1:30 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
<=100 is not a valid boolean expression, change it to "score <=100". Same on line 4
25th Apr 2021, 1:02 AM
Benjamin Jürgens
Benjamin Jürgens - avatar
+ 1
Thanks a lot!
25th Apr 2021, 1:23 AM
Brahian Suárez
Brahian Suárez - avatar
+ 1
BroFar love u!
25th Apr 2021, 2:21 AM
Brahian Suárez
Brahian Suárez - avatar
0
https://code.sololearn.com/cm6JX4igLpLu/?ref=app While comparing, the correct syntax is (x< y and x>z) for which you've used a wrong syntax. Secondly, for elif statement, you've used (elif grade) which should be (elif score) Hope you'll keep them in check while doing coding in future.. cheers buddy
26th Apr 2021, 4:35 PM
ITESH RAJEEV
ITESH RAJEEV - avatar