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
rishu misra
373 Pointslooping in list
Here is a multi-dimensional list of musical groups. The first dimension is group, the second is group members.
Can you loop through each group and output the members joined together with a ", " comma space as a separator, please?
musical_group = [
[Robin,sara,gytru],
[Steve,robert,camillie]
[biyug,dyutn,aseda]
]
print(",\n".join(map(str, musical_group)))
I have to use join method in for loop.How to do this?
please don't give instruction.Give full answer.
1 Answer
David Watrous
7,064 PointsIf I understand your question, the following should work:
musical_groups = [['Robin','Sara','Gytru'], ['Steve','Robert','Camillie'], ['Biyug','Dyutn','Aseda']]
for group in musical_groups: print(", ".join(group))
(Note: I changed the list name slightly and formatted the group member names as strings.)
DaJuan Harris
Courses Plus Student 540 PointsDaJuan Harris
Courses Plus Student 540 PointsI'm not sure exactly what the question you're working on, but I can guess.