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

Problem with task 3 Python Basics

I'm unable to do task 3 :'( and I've no idea how to have the right answer ! I don't understand...

days_alive.py
age = int(23)

days = int(23*52*7)

summary = 

3 Answers

Hi Lucie

Task 3 asks you to create a variable named summary where you substitute the {} for your variable days. As stated above this is done using the format method of the string function. On another note you don't need to convert your values to integers as the compiler will pick this up automatically. So only convert datatypes when you have the following scenario. For example you would attempt to convert from a string to integer when you have something like this a=23 and b="25" and c= a * b which would throw an error as b is a string a not an integer. So the correct approach would be c = a * int(b).

age = 23

days = 23*52*7

summary = "I am {} days old!".format(days) 
# you could convert days to a string if you wanted to but its not needed.  

hope this helps a bit with datatypes as well.

akak
akak
29,446 Points

The answer is

summary = "I am {} days old!".format(days)

You can look up again this https://teamtreehouse.com/library/python-basics/ins-outs/string-formatting video for explanation how and why :)

Thank you ! I've tried so many possible answers but it wasn't the exactly one :) I've to work a lot ^^...