+ 1
Where is the problem please tell me 🥺
age=input("what is your age:") B=2024-age print(B)
4 ответов
+ 1
age is an string when you try to operate with an integer, you have to use int() function (or float() for a decimal number) to convert it into a number and operate with that, you can make it directly conver into an integer with int(input()).
you cannot operate mathematically with strings, but you can still "+" to join two of them, for example, when printing "B", you can use print("Then, your birth year is: "+str(B)) to make it cooler and more user friendly.
if you dont want to convert "B" into a string (using str()), you can use print("text", B) for printing two separate statements on a single line. you can use this as much times as you want at the same print() function
+ 4
# inputs for code cosch without text
age = int(input())
+ 4
Vz
+ 1
age = input("What is your age: ")
B = 2024 + int(age)
print(B)
In Line 2 you need to convert your input into integer before adding.
or
you can simply change first line to
age = int(input("What is your age: "))