In python I don't seem to be understanding the return function. Why use it when I could just print it?
def maximum(x, y):
if x > y:
print(x)
elif x == y:
print('The numbers are equal')
else:
print(y)
maximum(2, 3)
This code gives me 3
. But using return it does the same exact thing.
def maximum(x, y):
if x > y:
return x
elif x == y:
return 'The numbers are equal'
else:
return y
print(maximum(2, 3))
So what's the difference between the two? Sorry for the mega noob question!