Computer Science, asked by gerald4, 4 months ago

Write a program to create a dictionary from an existing list of

numbers. The dictionary will have every element of the list as key

and the frequency of the elements as value​

Answers

Answered by jai696
8

\large\mathsf\color{pink}{Solution\: using\: python\: 3}

def create_freq_dict(l):

obj = {}

for n in l:

if n in obj:

obj[n] += 1

else:

obj[n] = 1

return obj

l = [2, 5, 1, 5, 2, 1, 3, 3, 4, 4, 5]

print(create_freq_dict(l))

\large\mathsf\color{lightgreen}useful?\: \color{white}\longrightarrow\: \color{orange}brainliest!

Similar questions