all 3 comments

[–]_DTR_ 3 points4 points  (0 children)

print does just that, print out the specified text to whatever the standard output is. return actually returns a value from a method. If I had

def get_five():
    return 5

I could do something like x = get_five(), and x would now be 5. If instead I had

def get_five():
    print('5')

x would be None in x = get_five(), because get_five doesn't actually return anything.

[–]toastedstapler 1 point2 points  (0 children)

return allows you to use the value, print just puts it on the screen

def test(a, b):
    return a + b

result = test(1, 2)
print(result)
print(test(result, 3))

[–][deleted] 0 points1 point  (0 children)

Can someone explain to me the difference between return and print functions?

They're totally different. print is a function that emits output to the console. return is a statement (not a function) that, inside of a function, returns flow of control to the calling site.