Last active
January 27, 2021 09:18
-
-
Save Turux/69132ee8b1d32f58e9977b0ab444b20b to your computer and use it in GitHub Desktop.
Summary of a Python list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @Brief: A function that takes a python list and returns a Dict of a summary of entries and thier number of occurrences | |
# @Param: input_list -> Any list of elements | |
# @Return: result -> A Dict containig as many keys as the unique elements of input_list | |
# The value for each key is the number of occurance of each unique element | |
def summary(input_list): | |
result=dict() | |
keys=list(set(input_list)) | |
for key in keys: | |
result[key]=input_list.count(key) | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment