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.
Alon RozmarinCourses Plus Student 2,083 Points
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,161 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.