Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics (2015) Python Data Types Age Calculation

adding value of years and days to my age

This is the question...

Great! Now we need to multiply the number years by the number of days in a year. We'll ignore leap years, so just multiply years by 365 and assign it to the variable days.

However I keep getting the...

Bummer! Your days variable has the wrong value. Be sure to assign it to the product of years and 365.

age.py
years = 27
years *= 365
days = 365

1 Answer

Charlie Gallentine
Charlie Gallentine
12,092 Points

The first line looks good:

years = 27

However, it gets a bit off in the second line. When you write:

years *= 365

You are multiplying your age in years by 365, however, you are saving that value back in the years variable rather than passing it to a new variable called "days":

The next line,

days = 365

is initializing a new variable named "days" and storing the value of 365 in it. In actuality, "days" should contain the number of years multiplied by 365:

days = years * 365

In total what should be the code up through the 2nd part of the challenge:

years = 27
days = years * 365

The last part of the question will ask for a variable "weeks" which will be "days" divided by 7. In that case, make sure to initialize the new variable "weeks" to equal "days" divided by 7.

Hope that helps!