0
Where do "none"s come from ?
def max(x, y): if x >=y: ### return x print (x) else: ### return y print (y) print(max(4, 7)) z = max(8, 5) print(z)
5 odpowiedzi
+ 1
look in above code u will get output as
7
None
8
None
because the function max() is not getting any value in return.. i know it's printing the right answer.. but the second and fourth line of the Output says that... it doesn't get any value from the function {when it reaches outside the function i.e. at line "print (max(4,7))"} 👈this line waits for a value but it gets nothing back from the function..
and the print statement just prints the values.. it doesn't transfers values.. return does that..
now if u just change the code.. as this https://code.sololearn.com/c1QC59f0LlmV/?ref=app
then u will find that the if the condition of "if statement" is true then it will "return x" to the function.. and if the condition is false it will "return y"
+ 1
oh I GOT IT !! Thank u so much !!
0
since THERE'S no return from the function
0
sorry... but I'm still confused... what's the different between return and print ?? they look similar to me...
0
np ;)