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 Types and Branching Strings

mohan Abdul
PLUS
mohan Abdul
Courses Plus Student 1,453 Points

how do you join combine two variable labels together like it did in the task. I have been trying to do it on tree house

work space.

1 Answer

rydavim
rydavim
18,771 Points

Are you referring to the first question, which concatenates strings?

action = "got" # saves the string 'got' to the action variable
exclamation = "You " + action # creates a string variable called exclamation and combines 'You ' and action (which has a value of 'got')
exclamation += " this!" # += is short-hand for setting something to it's current value, plus whatever you're adding - in this case, the string ' this!'
print(exclamation) # print out the current value of exclamation, after all the code above has been executed

Hopefully that answers your question, but if that isn't the quiz you're referring to or if you have any follow-up, let me know and I'll be happy to help. If you need assistance with something you're working on in workspaces, please post a snapshot using the camera icon towards the top-right of the workspace. Happy coding!