K
K
kuzmatop12022-01-18 11:02:45
Python
kuzmatop1, 2022-01-18 11:02:45

Throws an error for the python code below. Error type: rollerblades_list[i_rollerblades] = 0 IndexError: list assignment index out of range. What's wrong?

for i_people in people_list:
for i_rollerblades in rollerblades_list:
if i_people <= i_rollerblades:
successful_rent += 1
rollerblades_list[i_rollerblades] = 0
break

print('\nMost people who can rent rollerblades: ', successful_rent)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
galaxy, 2022-01-18
@kuzmatop1

i_rollerblades is NOT the index of the rollerblades_list

>>> rollerblades_list = [100, 10, 1]
>>> for i_rollerblades in rollerblades_list:
...   print(i_rollerblades)
...
100
10
1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question