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

Devan Laton
Devan Laton
602 Points

Im not sure what i need to do.

If someone could help me understand this better that would be great.

groups.py
musical_groups = [
    ["Ad Rock", "MCA", "Mike D."],
    ["John Lennon", "Paul McCartney", "Ringo Starr", "George Harrison"],
    ["Salt", "Peppa", "Spinderella"],
    ["Rivers Cuomo", "Patrick Wilson", "Brian Bell", "Scott Shriner"],
    ["Chuck D.", "Flavor Flav", "Professor Griff", "Khari Winn", "DJ Lord"],
    ["Axl Rose", "Slash", "Duff McKagan", "Steven Adler"],
    ["Run", "DMC", "Jam Master Jay"],
]
for member in musical_groups:
    print(", " + musical_groups)

1 Answer

Steven Parker
Steven Parker
231,236 Points

Remember that musical_groups is the master list of smaller lists. So in your loop, what you are calling "member" is actually one of the smaller lists which contains a group with several members. But functionally, the name is not important as long as you don't get confused by it.

In the print statement inside the loop, you may want to use Python's "join" function to create a comma-separated list from member (the group). If you need a refresher on how it is used, take another look at this part of the Split and Join video.

Devan Laton
Devan Laton
602 Points

I changed my code to this

musical_groups = [ ["Ad Rock", "MCA", "Mike D."], ["John Lennon", "Paul McCartney", "Ringo Starr", "George Harrison"], ["Salt", "Peppa", "Spinderella"], ["Rivers Cuomo", "Patrick Wilson", "Brian Bell", "Scott Shriner"], ["Chuck D.", "Flavor Flav", "Professor Griff", "Khari Winn", "DJ Lord"], ["Axl Rose", "Slash", "Duff McKagan", "Steven Adler"], ["Run", "DMC", "Jam Master Jay"], ] for member in musical_groups: member = (", ").join(musical_groups) print(member)

I'm not sure if its the order that i have this in thats the problem. i'll go check now. Like im thinking the join function needs to be above to "for" loop. also thank you for all your help with my other questions. everything has been very clear and ive been able to get all the other challenges done because of your help.

Steven Parker
Steven Parker
231,236 Points

You probably don't want to reassign the loop variable "member' inside the loop, so create a different variable to hold the string made with the "join" function. Also, you'll want to create that string using the loop variable and not the master list.

And when posting code, always use Markdown formatting to preserve the code's appearance.