在最后一个循环中,我们将允许玩家猜测代码 10 次,如果他们猜对了则停止循环。

  • 在函数外部,创建一个名为 y 值为 -115Integer Variable
  • 添加一个 Loop with Range 并将范围更改为 10.
  • 使用 Return Variable 调用函数 guess_code
  • 将返回变量命名为 guess 并使用参数 y

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)