+ 1

why this program is giving me error

#list of position holders student=["billgates","elonmusk","jeffbezos","mark zuckerburg"] counter=0 Max=len(student) while counter<=Max: print("1 "+student[counter]+"-_-") counter+=1 Output 1 billgates-_- 1 elonmusk-_- 1 jeffbezos-_- 1 mark zuckerburg-_- Traceback (most recent call last): File "./Playground/file0.py", line 6, in <module> print("1 "+student[counter]+"-_-") IndexError: list index out of range

23rd Jun 2020, 3:19 PM
Nobleguy
Nobleguy - avatar
3 Antworten
+ 2
Or: while counter < Max:
23rd Jun 2020, 3:30 PM
Russ
Russ - avatar
+ 1
Length starts with 1 and index with zero.
23rd Jun 2020, 3:23 PM
Sandra Meyer
Sandra Meyer - avatar