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

I didnt understand the question properly,can anyone help me through how to code this?

Which ones are groups and which ones are members?

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 group in musical_groups:

1 Answer

jmac pd
jmac pd
11,490 Points

Hello.

Are you asking what the 'group' is in "for group in musical_groups"?

it is just a variable and just means "for x in musical groups" where 'x' equals the iteration.

if you ran this in your console:

for group in musical_groups:
  print(group)

each list would print from musical groups. I guess each iteration here would be the musical group

if you ran

for group in musical_groups:
  for item in group:
    print(item)

And the iterations here would be the members of each group. You would return each item in the list from the list of groups in the musical group.

Doe this help? *edited for clarification

maybe it would be more pythonic if I wrote it like this:

for group in musical_groups:
  for member in group:
    print(member)

Best,

THanks for the help!!!Highly appreciated.