+ 1

Why is this index out of range?

I’ve been trying to solve the Pig Latin puzzle in Python. For the life of me I can not figure out how I keep getting an index out of range error Inside my while loop. Can someone please explain? nonpig = str(input("")) pig = [] first = "" nono = [nonpig.split()] i = 0 while i <= len(nonpig): first = nono[0][i][0] pig += (nono[0][i][:2] + first + 'ay') i += 1 print (pig)

5th Mar 2020, 3:55 AM
Noah
2 Réponses
5th Mar 2020, 7:28 AM
Oma Falk
Oma Falk - avatar
0
Instead of i<=len(nonpig) Put i<len(nonpig) and try... But follow above @Oma's advise to get better answers..
5th Mar 2020, 8:19 AM
Jayakrishna 🇮🇳