Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Nathan Noye
4,370 PointsSelecting a certain item in a For In loop
Hey fam,
I'm trying to build an app where it lists 5 or so things and outputs them to a label. Only issue is following the DRY method, I had to use a For In loop so I wouldn't be rewriting a bunch of code. My only issue is when I output this to a Label, my label on displays the bottom item. Is there a way I can make it so it displays everything as a list? for example this is what is should look like
- eggs
- bread
- milk
but it appears as this
- milk
Thanks!
anything helps!
1 Answer

harrygulliford
5,792 PointsHint: string concatenation, then assign the concatenated string to the label after the loop has run.

Nathan Noye
4,370 PointsThats what I had done initially
lblWork.text = "(randWork)"
only thing is instead of coming out at
- milk
- eggs 3.butter
it came out as 3.butter
it only showed the last item. Any way of making it show all in a list form or sending each item to it's own label?
Note - my code is correct for concatenation but the browser keeps changing it on my side so I'm not sure if the forward slash is appearing or not.
Nathan Noye
4,370 PointsNathan Noye
4,370 PointsNote - I need it to appear as a list in a single label