EmTee Gaming
EmTee Gaming

Reputation: 3

IndexError: string index out of range keeps coming up

I am learning the app Jar module so I decided to make an encoder but I keep getting this error and I don't get what it means. I have looked it up on here and it talks about indexes but I haven't got any I don't think. My code is below an I hope you can help. This is the error

Upvotes: -2

Views: 44

Answers (1)

ingvar
ingvar

Reputation: 4375

Note that indexes in string in Python starts from 0 (index of the first symbol) and ends with len(string) - 1 (index of last symbol). In your code, you have counter <= numLetters, so you have error trying access symbol with counter index while the maximum index is counter - 1, use counter < numLetters instead.

Upvotes: 0

Related Questions