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

I followed the instructions to the best of my knowledge and I have no idea what to do!

I am confused as to how to include the variable days into my code.

age = int("30")
days = int (age *52 *7)
summary = str("I am" + days(int) ys old!")

2 Answers

Hi Alaina,

Whenever you need to assign a number to a variable you can do so directly. You don't have to make it a string literal first and then convert to an integer.


age = 30

You can do the same for days. Just do the calculation and the result will already be an integer.

For the 3rd task it's probably easiest to solve it using the format() method.

If I wanted to create the string "I am 30 years old" as an example you could do it like this:

summary = "I am {} years old".format(age)

In this example, the curly braces will be replaced with whatever the value of age is.

Like Jason said... You don't have to typecast your variables. So:

age = 30

is fine. The last line, you omitted a quote.

summary = "I am" + days +  "yrs old!"

Again, no need for the explicit type conversions. Python is smart enough to figure that out.

You do have to convert days to a string if using string concatenation. Also, you're not allowing for spaces around days