+ 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
2 Answers
+ 2
Or:
while counter < Max:
+ 1
Length starts with 1 and index with zero.