Lesson 6 of 34

Strings: Playing with Text

9 min 20 XP

Strings come with useful tools: upper() makes capitals, lower() makes small letters, and len() counts the characters.

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

With an f-string, you can put variables straight into text: write f before the quotes and put the variable inside { }.

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

Indexes start at 0: name[0] is the first character and name[-1] is the last.

Challenge

+20 XP

first = "Priya" and last = "Kumar". Print the full name "Priya Kumar", then print its length on the next line.

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.