Like many languages, python can coerce values of certain types to something else. Unlike javascript, python is bit more strict about type casting.
age = input ("Enter your age: ")
print ("You are " + age + " years old.")
age = int(age)
print ("You will be " + str(float(age + 10)) + " years old in the year " + str(2022 + 10) + ".")
F-Strings
Similar to javascript’s own template literals, Python has its own way of evaluating and formatting strings
age = input ("Enter your age: ")
print ("You are " + age + " years old.")
age = int(age)
print (f"You will be {float(age + 10)} years old in the year {2022 + 10}.")
What’s your Reaction?
+1
+1
+1
1