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 trialYURI PAPINIAN
11,838 PointsIs it possible?
Can I solve this problem by only using comprehension lists?
Given an array of ints, return the number of 9's in the array.
array_count9([1, 2, 9]) → 1 array_count9([1, 9, 9]) → 2 array_count9([1, 9, 9, 3, 9]) → 3
2 Answers
Steven Parker
231,248 PointsWould combining one with a "len" function count?
array_count9(a):
return len([n for n in a if n==9])
YURI PAPINIAN
11,838 PointsThank you. I really appreciate your help.