17 步:为什么 while 循环不是无限的?让我们仔细看看使用errorr测试用例。

while循环不是无限的,因为我们用.upper()大写错误地更改了每个r !每次循环运行时,它都会找到一个r并将其更改为R 。最终,所有的r都变成了R 。对于条件, rR不同。最终r不再出现在单词eRRoR中,这导致循环停止!

  • while循环的最后一行输入此代码: print( word_list )查看输出控制台

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)