Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics (Retired) Things That Count Things That Count

Harsh Kumar Woike
Harsh Kumar Woike
204 Points

problem (things that count)

I have been given 3 tasks in python basics 'things that count' section. the three tasks are: 1) Create a variable named 'age' that contains your age. (i have completed this task) 2) Now, create a variable named 'days' that is your age multiplied by 52 and multiplied by 7. (i completed this too.) 3) Finally, create a new variable named 'summary' that inserts days into the string "I am {days} days old!" I am not able to complete the 3 task which asks me to create a new variable named 'summary'. please help. thanks.

1 Answer

Are you using the string.format() method? I'm guessing you might have written this:

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

... which will throw a KeyError. Instead try one of the following:

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

or 

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

[MOD: Added ```python formatting -cf]