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

Antonio Velardo
PLUS
Antonio Velardo
Courses Plus Student 111 Points

please how do i do that ? Finally, create a new variable named summary that adds the string version of days into "I am {

i don't really understand how it works i am lost

days_alive.py
age = 38
days = ( age * 52) * 7
summary = 

2 Answers

J.T. Gralka
J.T. Gralka
20,126 Points

Antonio Velardo,

The final step of this code challenge asks you to "Finally, create a new variable named summary that adds the string version of days into 'I am {} days old!'."

The opening and closing curly braces in the string should clue you in that you need to use the format() method of the str class to replace the curly brackets with the days value. See if you can look back in this stage to see how Kenneth uses the format() method on strings to accomplish something like this.

If you're still stuck, feel free to reply.

Antonio Velardo
Antonio Velardo
Courses Plus Student 111 Points

please i am stoked give me more int i don't really understand what to do , i have been stoked two days on this small task

i undetand i need to put format () but it does not make sense to me and i am not even sure i undestood the question

J.T. Gralka
J.T. Gralka
20,126 Points

Antonio Velardo,

Imagine we had a script that looked like this:

day_name = 'Saturday'
month = 'August'
day_num = 8
year = 2015

message = "Today is {}. The date is {} {}, {}.".format(day_name, month, day_num, year)
print(message)

Notice that we add opening and closing curly brackets inside the message string to signify to the format method that that is a placeholder for content. Then, when we call .format() on the string, we pass in arguments in the order we want them to be inserted into the placeholders in the string.

Check out Mar Bocatcat's example below. It's another example of using the format() method. This should help you understand the format method for strs, and hopefully it helps you answer the code challenge.

Good luck!

J.T.

nazia zaman
nazia zaman
1,410 Points

Hi, i'm stuck on the same thing and have tried everything. Could you just pls give us the solution so we can move forward? It'll be really appreciated! thanks! :)

Mar Bocatcat
Mar Bocatcat
7,405 Points

Nazia Zaman,

You might want to search up .format() and find more information. But format() is used to fill in the place holders {} in your string like so: <html> <p>

str ='Nazia' | str2 = 'Python' . this equals to = 'Hi! I am {}, I am learning {}'.format(str,str2) the result will be = Hi! I am Nazia, I am learning Python.

</p>

</html> Please let me know if you need any further explanation

Mar Bocatcat
Mar Bocatcat
7,405 Points

Hi Antonio,

You might want to search up .format() and find more information. But format() is used to fill in the place holders {} in your string like so:

str = 'Antonio' str2 = 'Python' 'Hi! I am {} ,I am learning {}'.format(str,str2) print result will be = 'Hi! I am Antonio, I am learning Python'.

Please let me know if you need any further explanation.