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 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,885 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,885 Points
name = "mahdi"
subject = "Treehouse loves " + name

thanks passed but was my code wrong ?

Antonio De Rose
Antonio De Rose
20,885 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