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

Adam Franklin
seal-mask
.a{fill-rule:evenodd;}techdegree
Adam Franklin
Python Development Techdegree Student 2,096 Points

Can anyone help me?

Stuck on this task and can't seem to figure it out?

Can anyone see my error?

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

for group in musical_groups: 
        if len(group) == 3: 
            print(comma.join(group)) 

2 Answers

andren
andren
28,558 Points

The issue is that you are printing the list out twice, the challenge only wants it printed once. While not explicitly stated, in the second task you were supposed to change the for loop from task 1 rather than add a new one. If you remove the first for loop in your solution then your code will pass.

Also as an aside try to avoid making multiple questions for the same challenge, or at least delete your old questions before making a new one. If you don't then people might provide answers to your old posts without realizing you have already solved the issue. I've gone ahead and deleted your two other posts for you.

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 28,720 Points

You have the right idea-- the challenge wording wasn't entirely clear. Part 1 code works great. But part 2 fails, because the automated test wants is to only see the trios, not the lists from part 1. So if you comment out (or leave out the code from part 1, you will pass the "trio" tests for part 2 of the challenge.

Good luck with Python, it's a worthwhile journey!

comma = ", "
# for group in musical_groups:
#    print(comma.join(group))

for group in musical_groups: 
        if len(group) == 3: 
            print(comma.join(group))