0

Can anybody please tell me what is wrong with this code.Whenever I try to run this I end up with an invalid syntax error.I'm a beginner, I'd be grateful if you can guide meThank you in advance!

average = 0 highest_num = 0 lowest_num = 0 total_students_mark = 0 for total_studenrts_mark in range (0,19): student_mark = int(input("Enter the student's mark : ")) if student_mark > 14 and < 61: # THE ERROR OCCURS HERE FROM THE GREATER SIGN highest_num = (highest_num + 1) elif student_mark > 61: print ("ERROR !") elif student_mark > 0 and < 6: lowest_num = (lowest_num + 1) else: print ("ERROR !") total_students_mark = (total_students_mark + student_mark) average = (total_students_mark / 20) print ("The average : ", average) print ("The lowest : ", lowest_num) print ("The highest : ", highest_num) 
2
  • 2
    student_mark > 14 and < 61 is nonsense. You want student_mark > 14 and student_mark < 61, or 14 < student_mark < 61.
    – deceze
    CommentedOct 21, 2020 at 13:20
  • You can't do a > b and < c. You need to either do (1) a > b and a < c, or (2) you can combine them with b < a < c which Python does allow.CommentedOct 21, 2020 at 13:21

1 Answer 1

4

if student_mark > 14 and < 61: should be:

if student_mark > 14 and student_mark < 61: 

and elif student_mark > 0 and < 6: should be:

elif student_mark > 0 and student_mark < 6: 

If you want to combine them, Python allows you to do that the way you would normally do it in mathematics:

if 14 < student_mark < 61: 

and:

elif 0 < student_mark < 6: 
0

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.