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

what the hell am i doing wrong

years = 23 years *= 365

age.py
years = 23
years *= 365

i did that and im still getting back errors

2 Answers

andren
andren
28,558 Points

The task asks you to multiple years by 365 and to store the result in a variable called days. You do not store the result of that multiplication in a new variable. You change the years variable instead, which is not what the instructions told you to do.

Create a variable called days and assign years * 365 to it like this:

years = 23
days = years * 365

And you will be able to pass the second task.

Ideally, we try to help folks find the answer, rather than coding it for them. Here, you've posted the answer.

andren
andren
28,558 Points

To be fair I also explain what was wrong with his original code.

In my experience people tend to understand what was wrong with their original code far better when they have a right example to compare it to, and by the time people post for help on this forum they are usually just looking for the answer anyway.

If the user specifically states that they are only looking for hints, not for the answer then I certainly respect that when I answer them. But for more ambiguous posts like this where the poster does not specify whether they want hints or the answer outright. I tend to give them both, as in my personal experience that tends to be more helpful.

I agree that simply posting the answer on its own without any explanation is not very useful, but I always try to pair the answer with an explanation of why the answer is what it is, and what the faults in the their attempted code is.

I also try not to show more than necessary, for example I only posted the solution to task 2, rather than the solution for the entire challenge.

I post quite a bit in this forum, and after adopting my current strategy I have received far more positive feedback on my posts, and far less issues with people misunderstanding parts of my post, that's why I tend to post like this.

When there's a lot of steps, I like to break it down like this. It can still get confusing though

# First, create a variable named years
years = 25 #Assign years to the number of years old you are
# multiply the number years by the number of days in a year
days = years * 365 # assign it to the variable days
# Make a new variable named weeks
weeks = days/7 # Give it the value of days divided by 7

thank you