mardi 27 août 2019

Why am i getting an elif syntax error here? How can i fix it?

I am trying to solve the hackerrank problem. Link - https://www.hackerrank.com/challenges/grading/problem

But in the code which I wrote, it's showing me syntax error with the 'elif' statement. No worries if the code itself has to be modified completely, but I want to understand the reason this error has occurred as a concept.

    n = int(input())
marks_list = []
for i in range(n):
    marks_list.append(int(input()))
mark = [73, 67, 38, 33]
def gradingStudents(marks_list): 
    for j in marks_list:
        if 100 > j > 38:
            a = str(j)          
            #b = str(j)[0]
            if '5' >= a[1] >= '3':
                return (int(a.replace(a[1], '5'))            
            elif a[1] >= '8': #showing syntax error
                return (int(a.replace(a[1], '0')) + 10)
            else:
                return j
        else:
            return j
    return marks_list 
print(gradingStudents(marks_list))

Aucun commentaire:

Enregistrer un commentaire