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

David Lassen-Diesen
David Lassen-Diesen
184 Points

In Python basics it asks you to add your age *365 for 365 days in a yr , it then asks you about variable days

In Python basics it asks you to add your age *365 for 365 days in a yr (excluding leap yr), it then asks you about variable days in the formula, this is where i need a bit of help please.


2 Answers

Charles Kenney
Charles Kenney
15,604 Points


You are evaluating the number of days correctly, you just aren't assign it to a variable days, as the instructions prompt you to.

Your code should look like this:

# declaring a variable `years`; assigning it to the integer 44
years = 44
# declaring a variable `days`; assigning it to the result of 365 * years
days = years * 365
# for the third part of the challenge
weeks = days / 7
Alex Koumparos
Alex Koumparos
Python Development Techdegree Student 36,887 Points

Hi David,

For this task you are being asked to do two things (on one line).

First, you are being asked to multiply the variable years by 365. What you are doing is multiplying a number literal by 365.

Then you are being asked to assign that value to a variable called days. That's just like what you did on the first line except you're assigning the calculation (strictly speaking, the calculation's result) to the variable instead of just the number.

For example, if we had a process that took 2 hours to complete and we stored that value in the variable hours we might want to express that in minutes, so we would compute the value as follows:

hours * 60

We can assign this calculation to a variable by putting the variable name and assignment operator before the calculation:

minutes = hours * 60

Hope this clears everything up for you