Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,862 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)