Resolved: Error "out of index" even with modulus
My code is below:
for char in text:
if char not in alphabet:
If shift is 5 and there is a "u" inside the text, it gives me the error "string index out of range" in line "output=output+alphabet[(pos+shift)%26]". Why can't I write "(pos+shift)%26" instead of calling a function that does the same? Thank you
Thank you for your question!
Your code is, in fact, absolutely correct. The error comes from the fact that the letter 'v' is missing in the definition of your
alphabet string :)