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

don't understand the question. can some one help?

shouldn't the code

for group in musical_groups: print(group)

be enough ? - dont understand the question

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"],
]

all_mems=[]

for group in musical_groups:
  all_mems.append(group)

print (str(all_mems))

2 Answers

Jimmy Sweeney
Jimmy Sweeney
5,649 Points

Is this for part 1 of the challenge? The challenge is asking you to print out a set of strings. Each string should be the members of a musical group separated by commas.

Right now your code simply prints out the original list as a string. So the following would do the exact same thing as your code.

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"],
]

print(str(musical_groups))

Notice that original list is a list of lists. So each iteration in the for-loop will give you a list. For instance, the first iteration through musical_groups is ["Ad Rock, "MCA", "Miked D."]. You will want to use the join() method in order to join the strings within that first iteration into a new string. And then do that for each iteration.

Hope that helps!

ok, so like ---

for grp in musical_groups: print(",".join(grp))

??

Jimmy Sweeney
Jimmy Sweeney
5,649 Points

That should do it. But you may want to add spaces after the commas. :)

thanks