← back to unit
Easy
# basics variables
Converting Between Types
Now that you know the main types, here's why they matter: input() always gives you back a str, even if it looks like a number. You can convert it using int(), float(), or str():
raw = input()
number = int(raw)
print(number)
This reads text, converts it to a real number, and prints it.
Your turn: read a number using input() (without converting it yet), then convert it to an int() in a second step, storing the result in a new variable. Print that new variable.
💡 need a hint?
pyb-var-convert.py
loading...