0

Return statement

def max(x, y): if x >=y: print (x) else: print (y) k= max(6,7) print (k) Do u know why when i replace 'return' to 'print' , it has ' None'. Please explain tks !

14th Jul 2019, 4:36 PM
Lewsijght G
Lewsijght G - avatar
2 Réponses
+ 6
you can try this: instead of printing in the function return the max value. def max(x, y): if x >=y: return x else: return y print(max(6,7))
14th Jul 2019, 6:51 PM
Lothar
Lothar - avatar
+ 4
Every function that doesn't explicitly return something, returns None instead.
14th Jul 2019, 4:44 PM
HonFu
HonFu - avatar