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 trialRobby Mansur
242 PointsOops! It looks like task one is no longer passing!
I don't see what I did wrong, I am on question 2.
name = ("robby")
tree = ("Tree")
house = ("house")
print("{}{}".varible(tree, house))
3 Answers
Christopher Beynon
10,258 PointsIn this question, your trying to make a variable with the value "Treehouse" with two STRINGS. What your trying to do is Print the value of two different variables.
This example works in the code challenge:
name = ("robby")
treehouse = ("Tree" + "house")
Here the value for "treehouse" is being set by the strings "Tree" and "house". The + operator when used in this scenario appends the two strings.
Hope this helps.
Chris Freeman
Treehouse Moderator 68,441 PointsWhen it says the first task is no longer passing it often is caused by a new syntax error. In this case .varible()
is not a string method. What you wanted is .format()
. That said, you need to create a new variable that is the two partial strings joined together.
Also, you do not need the parens around the strings:
name = "robby"
tree = "Tree"
house = "house"
print("{}{}".format(tree, house))
You can join strings in many ways:
simply add them, format them to a new string, or use the join()
method:
newstring = "firstpart" + " " + "secondpart" # <-- ok for short strings
newstring = "{} {}".format("firstpart", "secondpart") # <-- good when other formating or text is part of the format
newstring = ' '.join("firstpart", "secondpart") # <-- best when you have a lot to join (like a list of items)
Robby Mansur
242 PointsThank you~