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 (Retired) Things That Count Things That Count

Python Basics 2nd Challenge

First three tasks ask you to: 1) create age variable with your age 2) create days variable with your age*52*7 3) create decades variable by dividing your age by 10

And the last task is to: 4) create estimate variable that rounds how many decades you've been alive 5) create summary variable that says "I am {} days old! That's about {} decades!"

I am not sure what I am doing wrong.

days_alive.py
age = 23
days = 23*52*7
decades = 23/10
estimate = round(decades) 
summary = "I am " + days + " days old! That's about " + 
estimate + " decades!"

5 Answers

Eric Gernux
Eric Gernux
1,534 Points

For part 5 copy this exact code and it should work:

summary = "I am {} days old! That's about {} decades!".format(days,estimate)

It worked! Thanks a lot!

You need to use the variables:

days = age*52*7 decades = age/10

That makes sense. But even with these changes, it says something is wrong. Perhaps I don't fully understand the question, here it is just in case:

Finally, create 2 new variables, one named estimate that holds the rounded number of decades you've lived and, one named summary that adds the string version of estimate into "I am {} days old! That's about {} decades!" with the correct values added to it.

My updated code: age = 23 days = age*52*7 decades = age/10 estimate = round(decades) summary = "I am " + days + " days old! That's about " + estimate + " decades!"

If you need an estimate, try:

estimate = decades - (decades % 10)

This will set estimate equal to decades minus the remainder of decades divided by 10.

Still doesn't work.

Eric Gernux
Eric Gernux
1,534 Points

In one of the previous lessons they talk about the .format after strings

The answer should look like this:

summary = "I am {} days old! That's about {} decades!".format(days,estimate)

So would the answer look like this in your opinion:

age = 23 days = age*52*7 decades = age/10 estimate = round(decades) summary = "I am " + days + " days old! That's about " + estimate + " decades!".format(days,estimate)

If so, it still isn't working.

Eric Gernux
Eric Gernux
1,534 Points

You need the curly brackets in the answer still the .format(days,estimates) fills the first curly brackets with days and the second with estimates.

Eric, I am not sure what you mean?

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

It's failing because of you having estimate + " decades!" on a new line. Python doesn't automatically move from one line to the next, so you can't just throw new lines in willy-nilly. :D