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 trialAndrew Wyant
UX Design Techdegree Graduate 11,851 Pointswhat is the "letters" on line 2 doing here?
is it something built in to python that tells it to look for letters or just a name created ? If it is just made up why does it need to be there at all?
Also how does it know to print one letter per a line?
string = "hello"
for letters in string:
print(letters)```
1 Answer
Steven Parker
231,248 PointsThe for loop takes one letter at a time from the string into the variable "letters" and passes it to the print.
And the normal operation of print is to display what is passed to it and then go to the next line, which causes each letter to be on a line by itself.