Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,437 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!