Python Forum

Full Version: Calculating what year it is when you are 100 years old
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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]
input returns string, you have to convert it to integer before calculation
(Apr-26-2017, 08:00 PM)volcano63 Wrote: [ -> ]input returns string, you have to convert it to integer before calculation

Thank you... I can't believe I didn't see that -_-