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 (2015) Python Data Types String Formatting

kunal Kirange
kunal Kirange
299 Points

Getting bummer for str.format() function code task

I have used str.format() function correctly but still i am getting the error.when i tried te same code in sublime text its working.

Did anyone face the same issue? Please let me know

strings.py
name = "kunal"
subject = "Treehouse loves {}"
print(subject.format(name))

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! Your code is functional, yes. However, it does not meet the requirements of the challenge. The challenge wants the fully formatted string assigned to the variable subject. Currently, only the unformatted version of the string resides inside that variable. You need to use the format() method directly on the same line with the string to be formatted. Also note that the challenge does not ask you to print anything.

:bulb: Note: when doing these challenges it's a good idea to try to avoid doing things the challenge hasn't explicitly asked for. Even if functional outside the challenge, it can cause the challenge to fail.

I think you can get it with these hints, but let me know if you're still stuck! :sparkles:

kunal Kirange
kunal Kirange
299 Points

Hi Jennifer! thank you for your response.I am good to go now :)