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

Here is a multi-dimensional list of musical groups. The first dimension is Can you

can any one help please

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"],
]
# Your code here
for musical_groups in group:
    print(", ".join(musical_groups (group)))

In the for loop, switch musical_groups with group, since group is the element is iterating through.

1 Answer

I think you are thinking way to complicated, but let's break it down a bit.

It seems like you have confused the list that you are iterating through with the name that you are assigning to the individual elements:

# Your code here
for musical_groups in group: 

There is no list called 'groups', but you are trying to access it and assigning each element to 'musical_groups'

But there is a list named 'musical_groups' and you should try to pull the items out of that one:

for group in musical_groups: 

This means you are able to write the .join function in a shorter way:

print(", ".join(group)

Because you are only joining the elements of one list which is already a sub-list of musical_groups, so you don't need to pull it out of the main list again. You are already having it in named 'group' .

Hope this helps at least a bit.

Happy coding

thank you i do complicate things sometimes :(

Arihant Tripathy
Arihant Tripathy
8,764 Points

Your print statement has a missing bracket at the end.