str()
Converts any value to text.
Syntax
str(value)
Description
Converts values like numbers and lists to text. Required before combining with text (or use an f-string).
Returns
The text (str).
Example
Loading editor…
Expected output
Age: 36
When to use?
Combining a number with text, writing to a file, printing formatted to the screen.
Common mistakes
- ⚠️ "Age: " + age causes an error (text + number is not allowed); use str(age) or f-string.