Skip to content

Instantly share code, notes, and snippets.

@magnucki
Created October 16, 2013 17:08
Show Gist options
  • Select an option

  • Save magnucki/7011313 to your computer and use it in GitHub Desktop.

Select an option

Save magnucki/7011313 to your computer and use it in GitHub Desktop.
Creates a dict() where the key is the element and the value is the amount of times it is it the given list.
#Creates a dict() where the key is the element and the value is the amount of times it is it the given list.
def count_v(data):
output = dict()
for value in data:
print data[value]
if output.has_key(data[value]):
output[data[value]] += 1
else:
output[data[value]] = 1
return output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment