让我们创建另一个循环,以测试正确颜色但不正确位置的猜测。

  • 在函数内部使用另一个 Loop with Range 。将计数器更改为 peg_num ,范围更改为 4
  • 检查 if guess[peg_num]code 中而不在 colors_triedcolors_matched 中。
  • 如果符合,则添加一个名为 marker"black" Circle ,带有 xy 坐标,直径为 15
  • 如果符合,将 guess[peg_num] Appendcolors_matched 列表。

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)