Jan-03-2018, 10:13 AM
Hello!
I am getting an IndexError, and not sure why? My goal is to print out the higher numeric list element.
Thanks a lot!
I am getting an IndexError, and not sure why? My goal is to print out the higher numeric list element.
def mag(var): pos=0 mob=1 while pos < len(var): if var[pos]<var[mob]: pos = mob mob += 1 else: mob += 1 print posit returns this error:
Error:line 5, in mag
if var[pos]<var[mob]:
IndexError: list index out of range
i have already tried to change the code several times but the result is the same, may you help me to understand the problem?Thanks a lot!