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!
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
Hi 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
Szymon Dabrowski2,206 Points
The 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
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.
In the line
if len(musical_groups) == 3:, the value of
musical_groups does not change when the value of
group changes. Try comparing the length of the
group array instead.