Help a noob out

Arup Rakshit ar at zeit.io
Thu May 2 05:30:02 EDT 2019


The input function returns the string value. So you need to convert it to number before the math you do.


birth_year = input("What year are you born? ")
current_year = 2019
print(type(birth_year))
age = current_year - int(birth_year)
print(age)

—————

python3 age.py
What year are you born? 1989
<class 'str'>
30

Thanks,

Arup Rakshit
ar at zeit.io



> On 02-May-2019, at 2:50 PM, felixen989 at hotmail.co.uk wrote:
> 
> birth_year = input("What year are you born? ")
> current_year = 2019
> age = current_year - birth_year
> print(age)



More information about the Python-list mailing list