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

please help with this code is bothering me

someone help me solving this quiz code is bothering me

strings.py
name=" how much for this 3"
print(name.format(3))
subject="Treehouse loves {}"
print(subject.format(Treehouse loves {}))

2 Answers

David Evans
David Evans
10,490 Points

Hi ayub,

You're kind of close. The challenge isn't asking you to print anything.

The first step asks you to create a variable called name and assign it a value. That's easy enough and you have it.

name=name=" how much for this 3"

The second part of the challenge asks you to create a new variable called string and assign the text "Treehouse loves {}" to it. Then it wants you to use the format function to place your name into it.

The following code should work for you

name = "how much for this 3"
subject = "Treehouse loves {}".format(name)

You may want to review the video that was two steps before the challenge as it has some good content in there and a working example of this challenge in the Teacher's Notes.

Link to Video: https://teamtreehouse.com/library/python-basics/python-data-types/strings

Antonio De Rose
Antonio De Rose
20,885 Points
name=" how much for this 3" #correct, but this context, you can print your name.
print(name.format(3)) #not needed, you have to take this off.
subject="Treehouse loves {}" #partially correct, your name in the variable will have to be inside the placeholder, hint (use format)
print(subject.format(Treehouse loves {})) #no need