STEP 9: We are going to ask the player to guess how much money is in the bank, so we need to calculate that!

  • Click the SUBJECT tab in the toolkit, then and drag out List Sum.
  • Change the variable name to savings. Change the list argument in sum() to coins.

sum() adds up all the numbers in a list! We are storing that total in the variable savings. After the player guesses an amount, we will use conditionals to check if their guess is equal to savings.

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
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)