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

Grayden Kellogg
seal-mask
.a{fill-rule:evenodd;}techdegree
Grayden Kellogg
Python Development Techdegree Student 1,826 Points

Joining items in a multi-dimensional list.

Not sure where to go from here.

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
group_members = ", ".join(musical_groups)

for groups in musical_groups:
    print(group_members)
Grayden Kellogg
seal-mask
.a{fill-rule:evenodd;}techdegree
Grayden Kellogg
Python Development Techdegree Student 1,826 Points

I'm supposed to loop through each group and output the members joined together with a ", " comma space as a separator. Pretty lost

2 Answers

Steven Parker
Steven Parker
231,268 Points

Here's a few hints:

  • notice that "musical_groups" is a big list of smaller lists
  • if you looped through the big list, your loop variable would hold a smaller list
  • you could then join and print each smaller list
Grayden Kellogg
seal-mask
.a{fill-rule:evenodd;}techdegree
Grayden Kellogg
Python Development Techdegree Student 1,826 Points

As I was typing a reply I figured it out. Thank you for your help. I thought the way the multidimensional list was made was a little confusing. But it worked out. Thanks!

I still can't get this to work correctly, my approach is if the index is an odd number then join it with the other values of an odd index but that works in code but it fails the question, I was also trying to pass the index number to a function I defined which worked but didn't pass the challenge? Is there only 1 right answer for this?

Steven Parker
Steven Parker
231,268 Points

Sounds like you're getting to fancy. The challenge just wants you to show each list of members for task 1, and for task 2 do the same but only for groups with 3 members. There's no "even" or "odd" testing needed.

If you're still having trouble, start a fresh question (you should never add a question as an "answer") and be sure to show your code.