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 Introducing Lists Build an Application Multidimensional Musical Groups

Daniel Mula Tarancón
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Daniel Mula Tarancón
Full Stack JavaScript Techdegree Graduate 37,873 Points

Outputting members of multi-dimensional list

This the solution I chose:

for members in musical_groups [0]: print (members + ", ") for members in musical_groups [1]: print (members + ", ") for members in musical_groups [2]: print (members + ", ") for members in musical_groups [3]: print (members + ", ") for members in musical_groups [4]: print (members + ", ") for members in musical_groups [5]: print (members + ", ") for members in musical_groups [6]: print (members + ", ")

It seems to be wrong, I would like to know why is wrong and what would be the best answer if there are more than one.

Thanks very much in advance

2 Answers

You wouldn't want to explicitly refer to each musical group by it's index - that's a lot of effort and your code won't be right if the musical_groups array changes.

Try looping over the array musical_groups and then working on the array that is returned. To get you started, try:

for musical_group in musical groups:
#now musical_group is an array that contains members

From there, look into the join method to output the members.