r/PythonLearning • • Oct 05 '25

Help Request Don’t know why code isnt working

Post image

For school, I have been assigned a task to create a code that iterates through the 1d array and removes any integers below 0 and the string ‘placeholder’. However, I can’t seem to get it to work. Any help would be much appreciated.

63 Upvotes

25 comments sorted by

View all comments

0

u/SCD_minecraft Oct 05 '25
a = [1, 2, 3, 4, 5]
b = len(a) #5
a[b] #IndexError
a[b-1] #5

Lists start at index 0