Why does print work in my function but not return?


My code works as is below but on line 4 I originally had return y[key] and it didn't work. Why is that?

def hardcopy(x):
    for y in x:
        for key in y:
            print y[key]
print hardcopy(students)


Once a function returns, it exits and no longer runs.


Makes sense, so in this case using print takes the place of return (and acts kind of the same way) so the function can loop?


The way I use return in these sorts of ways, is via appending to an array.


def hardcopy(x):
    final = []
    for y in x:
        for key in y:
    return final


Ahh yes I remember this from a coursera python course I took early last year. Thanks for reminding me.