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

Please somebody help with the musical groups challenge I'm begging it keeps taking me back there it's annoying!!

I have been stuck for like 12 hrs please help I tried to skip it but it keeps taking me there!!PLEASE HELP ME...

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[0][2]]))
    print(", ".join([members[1][0]]))
    print(", ".join([members[1][1]]))

1 Answer

Josh Keenan
Josh Keenan
19,652 Points

You have been looking at it in the wrong way.

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

So this is the solution to the second challenge, I am starting a for loop to go over the list of lists. Then it is checking if the length of the group it is currently examining is equal to 3, meaning that there are 3 members in the group.

Then if it is it will print the group joined together with ", " a comma and a space, remember the join method is used on a string and then you pass it the thing you want to join together. So that means you use the style of the join, like a comma and a space, or a hyphen, and pass in your other item as an argument to the method.

Hope this helps and feel free to ask any questions! You got this!