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 (Retired) Ins & Outs String Building

Help understanding a question.

Hi, this is just a quick query for the following question: Fill in the blanks as if this was in the python interpreter:

"He's pining " ______ "for" _____" the fjords!" "He's pining for the fjords!" I know the answer to this question is to enter a '+' into each empty space, but I just don't understand why I have to enter a '+' in the first place. I have tried it in the python interpreter without the '+' and it brings out the full sentence "He's pining for the fjords!" absolutely fine. I was under the impression that the '+' was used to add more information into a string, so I don't really understand why a + is needed when there is no extra information needed to be added. I originally assumed that names would be added afterwards, but names would not make any sense in that sentence. I am hoping it is more the wording and me looking too much into it that has thrown me than the difficulty of the question, but I would appreciate some clarification if that is possible, Alistair.

2 Answers

Ricky Catron
Ricky Catron
13,023 Points

I believe this is just practice so you understand how the + works in python rather then an example of when to use it. Since this sentence would be what is called a "literal" there would be no need for the + and you could simply use "He's pining for the fjords!". But what if you wanted to chance it to "He's pining for the sky!" You would have to go back end edit it. In this case you should use a concatenated variable:

piningFor = "the sky"
sentance = "He's pining for " + piningFor

Goodluck! --Ricky

Ricky, Thanks a lot for that reply, it has really cleared it up for me, I feel comfortable moving forward now, and good luck to you too! Alistair