-1
n = int(input())
grades = []

for _ in range(n):
    grades.append(int(input()))

def gradingStudents(grades):
    for i in grades:
        if i > 37 and (5-i) % 5 < 3:
            print (i + (5-i) % 5)
        else:
            print (i)

result = gradingStudents(grades)
print(map(str,result))

If I change the printing method, it works fine but when I try printing with:

print(map(str,result))

it raises an error:

TypeError: 'NoneType' object is not iterable

I also tried with return but still won't work. Any help would be appreciated.

atachsin
  • 173
  • 10

2 Answers2

2

Your function gradingStudents doesn't have a return statement so it returns None

result therefore is None

map tries to iterate over None and fails.

nosklo
  • 217,122
  • 57
  • 293
  • 297
0

You can do this, I think this is what you actually want (maybe) :

def gradingStudents(grades):
    res = []
    for i in grades:
        if i > 37 and (5-i) % 5 < 3:
            print (i + (5-i) % 5)
            res.append(i + (5-i) % 5)
        else:
            print (i)
            res.append(i)
    return res
ZhouQuan
  • 1,037
  • 2
  • 11
  • 19