STEP 4: Now let's form a string to print out that will have the grade at each index of the list.

String formatting allows variables to be placed at specific places in strings by using {curly brackets}.

  • In , drag Insert Two Values into print_grades(). Make the string "grades[{}] = {}".
  • Within the parentheses of .format(), replace the two variables with index and grade.
  • .format() replaces the first {} with its first parameter and the next {} with the next parameter.

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)