10 步:如果用户猜对了,让我们停止循环。为此,我们将使用break语句。

break关键字告诉我们的程序在到达那行代码时停止运行循环。这行代码前面会有一个紫色和黄色········块,表示它嵌套了两次。

  • .say()中的字符串更改为"Great job, you guessed my number!"
  • 在逻辑中,在拖出Break 。将它放在程序底部的 if 语句中。

    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)