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
def max_num(nums):
maxNum = nums[0]
for i in nums:
if i > maxNum:
maxNum = i
return maxNum
#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)?
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.