Python Introducing Lists Build an Application Multidimensional Musical Groups

Shavez Memon
Shavez Memon
Python Development Techdegree Student 2,440 Points

Task2: What am I doing wrong?

Could you please tell me what I am doing wrong for Task 2? I seem to get an error. Thank you!

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 members in musical_groups:
    print(", ".join(members))

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

3 Answers

nakalkucing
nakalkucing
12,698 Points

Hi Shavez Memon! The instructions ask you to:

only print out the trios? It should still use the joined string format from task 1.

You still have all the members being printed out from the first task. They want you to change the for loop from the first task to only print the trios. Hope this helps. Happy coding! :)

Shavez Memon
Shavez Memon
Python Development Techdegree Student 2,440 Points

Ya I believe that's what I tried to do for the 2nd task and get this error: Uh oh, I found a non-trio!

My code for task 2 is:

for members in musical_groups:

if len(members) == 3:

    print(members)
nakalkucing
nakalkucing
12,698 Points

Hello again, Shavez Memon! Sorry it took so long to get back to you.

Is that all of your code for task 2? Because you still need the for loop too:

for members in musical_groups:

Hope this helps! :)

Shavez Memon
Shavez Memon
Python Development Techdegree Student 2,440 Points

Hello, thanks for responding.

No sir, my code (as shown above) is:

for members in musical_groups:

if len(members) == 3:

    print(members)
nakalkucing
nakalkucing
12,698 Points

Oops! Sorry, Shavez Memon, my bad. :blush: I missed that.

I should have caught this before: ", ".join(members) (Currently you just have print(members) )

Thanks for being patient with me. Let me know the result. :)