0

I has that code. and ın my school, I didn't see dict, I mean {} can I convert that code to d = [], I mean list...

L = ["1", "2", "1"]

def frequency3(L):
    d = {}
    for i in L:
        if i in d:
            d[i] += 1
        else:
            d[i] = 0
    return d

print(frequency3(L))

and I also want to make this code shows us just frequently number? so, output should be just "1" as above example.

I explain why you should my topic. but probably you didn't see. ın my code never being dict or built-in functions. I mean never ready code...

user9654395
  • 109
  • 1
  • 7
  • Scroll down a bit to find [this answer](https://stackoverflow.com/a/20872750/1222951). A [`Counter`](https://docs.python.org/3/library/collections.html#collections.Counter) is a dict subclass, so it does everything you need. – Aran-Fey Apr 28 '18 at 16:17
  • This looks like a question that was already asked here. – What Apr 28 '18 at 16:18
  • That link's answers are all about counter. but In my school, counter is not accepted... please open my topic. I mean, any ready code or built-in function are not be in my code. – user9654395 Apr 28 '18 at 16:21
  • What is the problem with your question that already has an answer? – What Apr 28 '18 at 16:29
  • In where? I said that in my school not acceptable in-built function and dict e.t.c. okay then can you show me answer? because I didn't see – user9654395 Apr 28 '18 at 16:30

0 Answers0