intermediate15 min
String Manipulation
Slicing, formatting, and common string operations
String Indexing and Slicing
Strings are sequences of characters — you can access individual characters:
String Indexing
Output
Run your code to see output here
Useful String Methods
String Methods
Output
Run your code to see output here
F-Strings (Formatted Strings)
F-strings let you embed variables and expressions directly in strings:
F-Strings
Output
Run your code to see output here
Check Your Understanding
What does `'hello'.upper()` return?
Exercise
Create a string 'Hello, my name is X' using an f-string, where X is stored in a variable. Then print it in uppercase.
Python will load on first run