Lesson 1.6
A value can be turned into another type:
int("5") # 5 — the string became a number
str(10) # "10" — the number became a string
float("2.5") # 2.5
Without int(), the string "5" stays text, and "5" + 1 does not work.
The program already has an age — it's written as text:
age = "14"
Add two lines of output and run the program:
14 + 1 — as a number, that is 15;" is a number"
— you get 15 is a number.The second number is not text, so turn it into text first. Both str(...) and an
f-string work: f"{number} is a number" — both ways are right.
int(...) turns text into a number, str(...) turns it back into text.
You cannot add "14" and 1: use int first. Print the answer both as a number and
inside a sentence; for the sentence use str(...) + " is a number" or an f-string.