Collections in Python

Kiran Kumar
Jan 19, 2023

--

๐Ÿšจ ๐œ๐จ๐ฅ๐ฅ๐ž๐œ๐ญ๐ข๐จ๐ง๐ฌ.๐‚๐จ๐ฎ๐ง๐ญ๐ž๐ซ: ๐‚๐จ๐ฎ๐ง๐ญ ๐ญ๐ก๐ž ๐Ž๐œ๐œ๐ฎ๐ซ๐ซ๐ž๐ง๐œ๐ž๐ฌ ๐จ๐Ÿ ๐ˆ๐ญ๐ž๐ฆ๐ฌ ๐ข๐ง ๐š ๐‹๐ข๐ฌ๐ญ

๐Ÿ–ฒ๏ธ If you want to count the occurrences of each item in a list, use collections.Counter. It takes one line of code to count using Counter. The code snippet below shows how it works.

๐Ÿ–ฒ๏ธ Not only is Counter shorter to write, but the execution time of Counter when working with a large list is also smaller compared to creating your own counter.s

youtube link for python playlist:

https://www.youtube.com/watch?v=-nitykYMYsc&list=PLfn1X0acn8m2kLEIb6N8m9RPp_WEXbBm6

--

--

Kiran Kumar
Kiran Kumar

Written by Kiran Kumar

Technophile with 12.5 years experience in IT industry | Java Technical Manager cum Architect

No responses yet