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

Multidimensional List, my code works if i copy and paste into VS code but the compiler on treehouse is throwing an error

i think i may just be thinking of this wrong, am i suppose to get them to all print on the same line? if so can you throw me a hint as to what method i shouldbe using?

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 groups in musical_groups:
    for x in groups:
        print(x + ", ")

1 Answer

Alex Koumparos
seal-mask
.a{fill-rule:evenodd;}techdegree
Alex Koumparos
Python Development Techdegree Student 36,887 Points

Hi Roger,

Your code prints every person on a separate line with a comma at the end of the line. The Challenge wants you to have a line for each group, and on each line it should list the members comma separated (but no comma at the end of the line). E.g, for the first group, it should like this:

Ad Rock, MCA, Mike D.

There is a built-in string method you can use, join().

Hope that helps

Alex

so i think i'm a bit closer but now the placement of mt comma is wrong, i think my brain has shut down...

listx=""
for x in musical_groups:
    for y in x:
         listx += y.join(", ")
print(listx)