What happens when you print a function that prints already

So I tried it.

def print_grades(grades_input):
for grade in grades_input:
print grade

print print_grades(grades)

And if you see: there’s an additional None that appears on my editor. Can someone explain what this is?

A function that doesn’t explicitly return a value, implicitly returns None.

def do_nothing():
    pass

print(do_nothing()) # None
def print_something():
    print('something')

print(print_something())

Output:

something
None

1 Like