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

David Garcia
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
David Garcia
Python Development Techdegree Graduate 11,254 Points

im doing something slightly different?

i must be doing something wrong but what could it be

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
print(musical_groups)
for group in musical_groups:
    groups = ", ".join(group)

2 Answers

Eric M
Eric M
11,545 Points

We want to print the groups one by one, not just run print(musical groups)

Your loop already creates a string groups of each group in musical_groups, but that string is overwritten everytime the loop runs

So, to print out each string, just do it at the end of the loop (before the loop runs again and string groups changes to be a join of the next group

i.e.

for group in musical_groups:
        groups = ", ".join(group)
        print(groups)
Eric M
Eric M
11,545 Points

Hi David,

You've got the right idea with your loop!

Each time you loop through you're reassigning what's in the string groups to be the joined list group contained in the list of lists musical_groups, so move your print statement inside the loop, and do the print of the joined string after it gets created. Each time the loop runs it will reassign what's in that string, then print it out.

Cheers,

Eric