第 5 步:我们现在已准备好处理用户可能因无效输入而导致的任何错误。让我们问这个问题!

  • 首先删除try语句下面的x · = · 5 · / · 0
  • 在图形和,将Ask for Integer拖入try语句内,缩进3次!
  • guess更改为scoops并将问题更改为"How many scoops would you like?"
  • 输入不是数字的输入将导致运行时错误并停止程序。不能有这种事!

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)