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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![alonrozmarin](https://uploads.teamtreehouse.com/production/profile-photos/11603663/micro_Gami_Man_YT.jpg)
alonrozmarin
3,493 PointsHi someone can help me?
I got it!
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(musical_groups) == 3:
print(", ".join(group))
else:
continue
2 Answers
![Szymon Dabrowski](https://uploads.teamtreehouse.com/production/profile-photos/11651799/micro_IMG_0090.jpg)
Szymon Dabrowski
2,207 PointsThe reason why I used group
instead of musical_groups
is because musical_groups
is a name that contains the multi-dimensional list and not actually defining either of the dimensions if that makes any sense.
The first dimension is group
and the second is group members
. So ["Ad Rock", "MCA", "Mike D."]
all together would be considered a group and, "Ad Rock", "MCA", "Mike D."
separately group members.
So the second part of the challenge asks us to only display groups
that have 3 members in them. So we can straight away tell that we need to use the first dimension which is the group
. You got the len()
function correctly to calculate how many members there are but selected the incorrect dimension in the list. and, you have also correctly compared all the groups to be equal (==
) to the number 3 which stands for 3 names in a group. So the only thing you have missing is the correct dimension to look through which is group
.
for group in musical_groups:
if len(group) == 3:
print(", ".join(group))
I hope this makes more sense for you as I was stuck on this part for a while myself.
![jb30](https://secure.gravatar.com/avatar/681668d7cc4c5486851384a0feddda37?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
jb30
44,806 PointsIn the line if len(musical_groups[0]) == 3:
, the value of musical_groups[0]
does not change when the value of group
changes. Try comparing the length of the group
array instead.