STEP 6: Let's combine our string and variable to make a sentence!

Data types tell us about the kind of data that is stored in a variable. In this example, we want to combine a string and an integer to form a sentence. Since they're different types, they can't be combined with just a plus sign +.

  • We need to tell the computer to pretend that the integer variable is a string by using str().
  • Replace "I am a sprite." inside .say() with "My area is " + str(8).

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)