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

Help with Task 2 please and thank you in advance.

Not sure what exactly I am doing wrong to cause the AssertionError: print("I feel like I am missing something important") print("Please explain as clear as possible")

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 musical in musical_groups:
    musical = ", ".join(musical)
    print("{}".format(musical))

if len(musical_groups) == 3:
    print(", ".join(musical_groups))

2 Answers

Cameron S
Cameron S
20,537 Points

Assertions are a systematic way to check that the internal state of a program is as the programmer expected, with the goal of catching bugs. In particular, they're good for catching false assumptions that were made while writing the code, or abuse of an interface by another programmer. Read more on Assertion use here

In your second code block

if len(musical_groups) == 3:
    print(", ".join(musical_groups))

muiscal_groups is a list containing lists of 7 different musical groups. Therefore, the len() of musical_groups is 7. You need to move your if statement inside your for loop to "print out the trios". See below:

for musical in musical_groups:
    if len(musical) == 3:
        print(", ".join(musical))

Thank you sir. So I was just had to loop it?