Python · Level 1 Basics

Text & f-strings

Change the case of text and build new text from variables with f-strings.

  • upper(), lower() and capitalize()
  • f"...{value}..." puts values into text

Text methods return a new string. An f-string (an f before the quotes) puts values inside {} straight into the text.

city = "paris"
print(city.upper())         # PARIS
print(city.capitalize())    # Paris
print(f"I love {city}!")    # I love paris!

Write name_tag(first, last) that returns the last name in capitals, a comma, then the first name capitalized, e.g. name_tag("grace", "hopper") → HOPPER, Grace.

solution.py
Test Suites Pending
Stdout