Calculating what year it is when you are 100 years old - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Calculating what year it is when you are 100 years old (/thread-3051.html) |
Calculating what year it is when you are 100 years old - dankim9000 - Apr-26-2017 I'm trying to figure out how to get the program to calculate what year it is when the user is 100 years old. The error that it gives me is: Traceback (most recent call last): TypeError: unsupported operand type(s) for -: 'int' and 'str' [code] print("The date is as follows:") import datetime now = datetime.datetime.now() print (now.year, now.month, now.day) name = input("Hi. Please enter your name: ") print("Hello", name) age = input("Please enter your age: ") print("You are going to be age 100 on the year", (now.year-age+100))[/code] RE: Calculating what year it is when you are 100 years old - volcano63 - Apr-26-2017 input returns string, you have to convert it to integer before calculation
RE: Calculating what year it is when you are 100 years old - dankim9000 - Apr-26-2017 (Apr-26-2017, 08:00 PM)volcano63 Wrote: Thank you... I can't believe I didn't see that -_- |