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))

31st Mar 2017, 7:18 AM
pavan jain
pavan jain - avatar
1 Answer
+ 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)
31st Mar 2017, 7:28 AM
Burey
Burey - avatar