警告:这个程序应该找到单词中每个出现的字母,但它陷入了无限循环!

  • 例如, "apple"出现了两次"p" (一个在索引 1 处,一个在索引 2 处)。
  • 点击运行并尝试在单词中找到s 。哦哦!这个循环是无限的!点击停止以结束程序。
  • 找到这个代码: word_list [ letter_index ] · = · letter并将.upper()添加到letter的末尾。
  • 这通过将找到的每个字母替换为大写版本来停止while循环!再找s

To navigate the page using the TAB key, first press ESC to exit the code editor.

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • 提交作品
  • 下个活动
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)