for some reason my code returns the value 50 but I am not sure why. In the end, I requested to see the solution and it turns out, it is the same as mine (except for the name of my variables)
#Write your function here
maxNum = nums
for i in nums:
if i > maxNum:
maxNum = i
#Uncomment the line below when your function is done
print(max_num([50, -10, 0, 75, 20]))
Could anyone please assist in identifying why the output is 50 (and of course marked wrong)?
We cannot tell from looking at the code but I suspect the return statement is inside the loop body.
Thank you very much for your reply my. The code in the message didn’t display as it did when I pasted it in. I have another check over my return statement.
For future reference regarding how to post code:
This really useful info thank you