3 min read
Input and Output
Prerequisites: Strings
print() writes text out; input() reads a line of text the user
types in, always as a string.
name = input("What is your name? ")
print(f"Hello, {name}!")
Common mistakes
- Forgetting that
input()always returns a string, even if the user types a number —input("Age: ")gives"25", not25. Convert it withint(...)before doing math with it.