# basics io

Building Messages with f-strings

An f-string lets you drop variables straight into a message. Put an f right before the opening quote, then wrap any variable in {}:

name = "Sam"
print(f"Hi, {name}!")

This prints: Hi, Sam!

Your turn: read a name, then an age (as a number). Print exactly: Hi, <name>! You are <age> years old. — using an f-string, with <name> and <age> replaced by what was read.

💡 need a hint?

pyb-io-fstring.py
loading...