I have just recently began to learn python. I am trying to find the lowest integer in the digits list. Instead I get this error:
Traceback (most recent call last):
File "H:/Python/untitled/08_python.py", line 32, in <module>
if digits[e] < temp:
IndexError: list index out of range
I realize that you can use min(digits) but I thought I would challenge my knowledge so far. I most likely made a simple mistake and am not diagnosing it properly. If I throw 0 in the list everything works fine.
digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
low = 0
temp = 0
for e in digits:
if digits[e] < temp:
low = digits[e]
temp = digits[e]
print(low)
eis each of the digits in the list. You can't just use those as index intodigitsagain, you don't have adigits[10].if e < tempandtemp = e. You don't need both atempandlow, by the way.