第 3 步:我们需要编辑函数中的循环,以便它使用在函数调用时传入的参数。

  • cheer()函数中找到创建 for 循环的行: ···· for · letter · in · "go" : ¬
  • "go"改为word 。现在,通过函数调用传入的任何值都将用于for循环!
  • 删除两个注释之间的代码。相反,调用带有参数"go"cheer()函数!
  • 点击运行。我们的代码更加高效和可读,但是程序的结果是一样的!

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)