0
Why does this code return answer and none when run
def max(x, y): if x >=y: print (x) else: print (y) print(max(4, 7)) print (max(8, 5))
1 ответ
+ 9
either use return instead of print in the max function:
def max(x, y):
if x >=y:
return (x)
else:
return (y)
print(max(4, 7))
print (max(8, 5))
or don't use print on max calls:
def max(x, y):
if x >=y:
print (x)
else:
print (y)
max(4, 7)
max(8, 5)
the reason behind the none value is a result of printing a function call which does not return anything (essentially returns none)