Python error: “IndexError: string index out of range”

前端 未结 4 670
遇见更好的自我
遇见更好的自我 2020-12-09 04:35

I\'m currently learning python from a book called \'Python for the absolute beginner (third edition)\'. There is an exercise in the book which outlines code for a hangman ga

4条回答
  •  悲&欢浪女
    2020-12-09 05:03

    You are iterating over one string (word), but then using the index into that to look up a character in so_far. There is no guarantee that these two strings have the same length.

提交回复
热议问题