#22 - Python Collections
By Ifeanyi Omeata

Hi, I am a Software Developer of 3-4 years specialising in React, Javascript, Node, NextJS, Express, Python, Django, Fast API, SQL and a few other technology stack, with a good background in Networking and Cloud Infrastructure. I am working to become a DevOps Solutions Engineer and happily married to my long time girlfriend.
Topics:
1. Counter from Collections
2. Defaultdict from Collections
1. Counter from Collections
>>Return to Menu
from collections import Counter
nlist = ["b", "e", "a", "e", "c", "e", "c", "d"]
print(Counter(nlist))
print(type(Counter(nlist)))
print(Counter(nlist)['e'])

from collections import Counter
nlist = ["b", "e", "a", "e", "c", "e", "c", "d"]
print(Counter(nlist))
print(type(Counter(nlist)))
print(Counter(nlist)['e'])
sentence = "The alphabet a to Z."
print(Counter(sentence))
print(type(Counter(sentence)))
print(Counter(sentence)['e'])

2. Defaultdict from Collections
>>Return to Menu
from collections import defaultdict
mydefaultdict = defaultdict(lambda: 'Sorry, not a key.',{'a':5, 'b':2})
print(mydefaultdict['c'])
mydict = {'a':5, 'b':2}
print(mydict['c'])

#End
Hope you enjoyed this! :) Follow me for more contents...
Get in Touch:
www.ifeanyiomeata.com
contact@ifeanyiomeata.com
Youtube: https://www.youtube.com/c/IfeanyiOmeata
Linkedin: https://www.linkedin.com/in/omeatai/
Twitter: https://twitter.com/iomeata
Github: https://github.com/omeatai/
Stackoverflow: https://stackoverflow.com/users/2689166/omeatai
Hashnode: https://hashnode.com/@omeatai
Medium: https://medium.com/@omeatai
© 2022






