Python Data Structure: Count the number of students of individual class
Write a Python program to count the number of students in an individual class.
Sample Solution:
Python Code:
from collections import Counter
classes = (
('V', 1),
('VI', 1),
('V', 2),
('VI', 2),
('VI', 3),
('VII', 1),
)
students = Counter(class_name for class_name, no_students in classes)
print(students)
Sample Output:
Counter({'VI': 3, 'V': 2, 'VII': 1})
Flowchart:

Python Code Editor:
Contribute your code and comments through Disqus.
Previous: Write a Python program to find the class wise roll number from a tuple-of-tuples.
Next: Write a Python program to get the unique enumeration values.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics