TypeError | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

TypeError

Traceback (most recent call last): File "..\Playground\", line 7, in <module> year = str((2018 - age) + 100) TypeError: unsupported operand type(s) for -: 'int' and 'str' Code: name = input ("Please Enter your Name : ") print("Your Name is :" + name) age = input("Please Enter your Age :") print("Your Age is : " + age) year = str((2018 - age) + 100) print("The year you will be 100 years old is : " + year)

28th Dec 2018, 5:06 AM
Dhruv Gupta
Dhruv Gupta - avatar
2 Answers
+ 5
After you convert the variable age to int, you need to change the fourth line to print('Your age is: ' + str(age)) or print('Your age is:', age).
28th Dec 2018, 5:57 AM
Anna
Anna - avatar
+ 4
Change the type of variable age to int like this:- age = int(input("Please Enter your Age :"))
28th Dec 2018, 5:11 AM
Pulkit Kamboj
Pulkit Kamboj - avatar