str() and bool()
Convert any object to text, or to True/False by its truthiness.
Beginner
str(4.7) → '4.7'; bool([]) → False; bool("0") → True (non-empty string).
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.