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
Josh Gold
12,207 PointsIs it okay to use the '+' to concatenate the variable with the string in Python?
Is it okay to use the '+' to concatenate the variable with the string in Python?
I noticed that Craig used a comma in the video instead, and I was just wondering if the plus operator was okay to use as well. It seems to work fine.
1 Answer
Steven Parker
243,266 PointsThe comma separates arguments, so in the video the method is being supplied two strings. But you can combine them into one string by concatenation to get similar results.
One difference might be that concatenation doesn't automatically provide space between the items being combined, but handling them as two arguments would.
Josh Gold
12,207 PointsJosh Gold
12,207 PointsThank you! I will remember to add spaces when concatenating strings with plus operator. It's just a personal preference for readability now. I might feel differently and do things differently later.