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 trialJordan Severo
708 PointsHow to put treehouse into X and name into Y
In I/Os on Python challenge task 3 of 3 states that I need to create a new variable named email_greeting= x loves y. where x is treehouse and y is name. I declared name="my name" and treehouse= "Tree" + "house". I've attempted multiple different things for step 3 and cant seem to get it.
3 Answers
boog690
8,987 PointsYou'll use a something called String Formatting. You can find the basics in the link that I sent. I don't want to give you the entire answer but hopefully it'll get you started.
Instead of X and Y, you'll use '{}' to hold the place. After that, you'll use the format function to specify exactly what you want in the first, second, third, etc. placeholders.
Stephen Bone
12,359 PointsHi Jordan
It looks like you're just about there and as I can't see what you're trying I can't say exactly where the issue lies but basically you just need to concatenate the variable treehouse to the string " loves " and finally the variable name. So it should look something like below:
name = "Stephen"
treehouse = "Tree" + "house"
email_greeting = treehouse + " loves " + name
Hope it helps!
Stephen Bone
12,359 PointsAlthough this does pass the challenge, having seen boog690's answer I checked the order of the course and this challenge does follow the String Formatting video even though for this challenge it seems a little unnecessary.
So if you're already familiar with concatenation and need further practice at String Formatting boog690's answer is probably the way ahead.
Jim Withington
12,025 PointsThanks! I thought it was going to be more complex than this!
Wolf <null>
5,060 PointsI have trouble understanding the str.format part in this. The link book690 showed didn't help me to understand.