1# Basic syntax:
2dict_of_counts = {item:your_list.count(item) for item in your_list}
3
4# Example usage:
5your_list = ["a", "b", "a", "c", "c", "a", "c"]
6dict_of_counts = {item:your_list.count(item) for item in your_list}
7print(dict_of_counts)
8--> {'a': 3, 'b': 1, 'c': 3}
1student_grades = [9.1, 8.8, 10.0, 7.7, 6.8, 8.0, 10.0, 8.1, 10.0, 9.9]
2
3samebnumber = student_grades.count(10.0)
4
5print(samebnumber)
1your_list = ["a", "b", "a", "c", "c", "a", "c"]
2d= {}
3for items in your_list:
4 d[items] = your_list.count(items)
5print(d)