第 7 步:让我们尝试改变循环的条件,看看会发生什么。这将控制它是否是无限的!

while循环的条件必须以True开始。否则,循环根本不会运行!

  • "This is a string."更改choice的值。 "hello" 。点击运行。现在会发生什么?

循环不会运行,因为choice确实等于"hello" ,所以它的初始choice != "hello"False

  • while循环条件中的字符串从"hello"更改为"no"然后运行提交前停止

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)