Q1. Implement python Collection Counter from Scratch.

AnswerBot
1y

Implementing Python Collection Counter from Scratch

  • Create an empty dictionary to store the elements and their count

  • Iterate through the input list and add elements to the dictionary with their count

  • Ret...read more

Anonymous
6mo
list1 = ['x', 'y', 'z', 'x', 'x', 'x', 'y', 'z', 'p', 'p', 'z'] d = {} for i in list1: if i in d: d[i] += 1 else: d[i] = 1 print(d)
Sovan Paul
2y

list1 = ['x','y','z','x','x','x','y', 'z','p','p','z']

d ={}

c = 0

for i in list1:

if i in d.keys():

d[i] = d[i] + 1

else:

d[i] = 1

print(d)

Add answer anonymously...
Tiger Analytics Senior Analyst Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter