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

what did I do wrong unknown?

age = 50 days = (age *52 * 7) summary = print("I am str{} days old!".format(days))

days_alive.py
age =50
days = age * 52 * 7
summary = print("I am str{} days old!".format(days))

1 Answer

Ryan Ruscett
Ryan Ruscett
23,307 Points

Hey,

You are close, it is definitely a good effort.

WHAT YOU DID Print is a function. You are trying to save a function that prints to the console. It doesn't actually return anything.

age =50
days = age * 52 * 7
summary = print("I am str{} days old!".format(days))

WHAT I DID Now, I did the age and multiplication different, just for the sake of doing it different. Yours works too but I wanted to show another way to do it for fun lol

What you need is a string, but {} indicates it's a formatted string. So str.format() allows me to format a string. The first argument is the string and the second argument is what goes into the {} within the string.

age = 30
days = 30 * (52 * 7)
summary = str.format("I am {} days old!", days)

Does this help clear it up for you? Let me know if not and I can explain it further.

Thanks!

Thanks, perhaps I missed it in the video lecture, your answer is clear. But I will need to do some independent search on how to use the 'format()' still to be comfortable with it. I am a true beginner Again thanks.

Ryan Ruscett
Ryan Ruscett
23,307 Points

Sure,

Here is a good tutorial.

Format in Python