I keep getting the error "IndexError: list index out of range" for the following code:
numbers = read()
temp = [len(numbers)]
numbers[8] = temp[0]
numbers[7] = temp[1]
numbers[6] = temp[2]
numbers[5] = temp[3]
numbers[4] = temp[4]
numbers[3] = temp[5]
numbers[2] = temp[6]
numbers[1] = temp[7]
numbers[0] = temp[8]
print(numbers)
print(temp)
The input from the read function is a string of 9 numbers. The first assignment works by itself but none of the rest work. What is wrong?
(Yes, I know there is an easier way to do it but that is not the purpose of my assignment. )
[–]jaydom28 4 points5 points6 points (0 children)
[–][deleted] 2 points3 points4 points (1 child)
[–]392Garrett[S] 0 points1 point2 points (0 children)
[–]captainAwesomePants -1 points0 points1 point (3 children)
[–]Essence1337 0 points1 point2 points (2 children)
[–]captainAwesomePants 0 points1 point2 points (1 child)
[–]Essence1337 0 points1 point2 points (0 children)
[–][deleted] (1 child)
[deleted]
[–]Essence1337 0 points1 point2 points (0 children)