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

Andras Andras
Andras Andras
7,941 Points

For loop horizontally? - Letter Game

Hello, I have noticed that previously the for loop generated vertical list but here, in Letter game it is all the letter are listed horizontally. Could you please explain why?

1 Answer

Steven Parker
Steven Parker
229,783 Points

It's not the loop, but the print statement.

Normally, a print will go to the next line each time you use it. But when you provide the option "end=''", you're telling it you don't want anything done after the text is put out. This makes sure that each item will appear directly after the previous one and on the same line.

After the loop, there's a print with an empty string and no end option that goes to the next line.

I was able to answer because I'd just seen another question on the same topic. But normally it's a good idea to provide a link to the course page you are working on along with your question.