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

python strings quiz

Hello i was learning some python when i stumbled upon this quiz it should be like this

strings.py
name = "mahdi"
subject = "Treehouse loves {}".format(name))
print(subject)
Antonio De Rose
Antonio De Rose
20,882 Points

generally speaking, your code would work, if you do like, as you did above except for the additional brace.

name = "mahdi"
subject = "Treehouse loves {}".format(name)#I took off your, additional brace, from the end
print(subject)

however, the given task, does not like, if you did it as such as it is asking you to use the concatenation operator

4 Answers

You need to use a + to combine the string and name. Still looking for an answer

Antonio De Rose
Antonio De Rose
20,882 Points
name = "mahdi"
subject = "Treehouse loves " + name

thanks passed but was my code wrong ?

Antonio De Rose
Antonio De Rose
20,882 Points

just as I mentioned earlier your code was right, see now, there are many ways in coding to solve a single same problem, you have solved in a way, but the question, over here has specifically, asked in a way, you have not done, otherwise, your coding is completely correct, except for that additional brace at the end.

alright thank you