Syncing account progress…

Back

Beginner · 10 min

Building messages

Combine text and values in a readable message.

Join text

Use + to join strings. Add a space yourself when words need one. Both sides of + must be strings in this example.

first = "Good"
second = "morning"
print(first + " " + second)

Output

Good morning

Put values in a message

An f-string starts with f before the quote. Put a variable inside braces to insert its value. Numbers can be included this way too.

name = "Ada"
count = 3
print(f"{name}: {count} books")

Output

Ada: 3 books

Building messages

  1. Find the spaces and punctuation in each message.
  2. Change a variable and predict the new message.

Try it yourself

Code runs on this device. When you are signed in, drafts sync to your account.

Build a book label

Keep name as Ada and count as 3. Use an f-string to store Ada: 3 books in message, then display it.

Practice