CodeLab Academy 📞 9936 6696
← Lessons 🐍 Python for Beginners

Variables and input()

## Variables ```python name = "Bat" age = 10 print(name, age) ``` ## Reading input `input()` gives back the **line** the user typed **as text**. ```python name = input() print("Hello, " + name + "!") ``` ## Reading numbers To turn it into a number, use `int()`: ```python a = int(input()) b = int(input()) print(a + b) ``` ## Several numbers on one line ```python a, b = map(int, input().split()) ``` > ⚠️ When solving problems, you don't need to write a question like `input("Enter a number: ")`. Print exactly what the output asks for, nothing more.
← Previous Next →

💡 Want to track which lessons you've read and solve problems for points? Sign up for free or log in.