+ 1
How to convert list to dict?
For example: l = [1,1,2,3,3,3,3] Need to get output, d = {"1": 2, "2":1, "3":4} Can anyone suggest
11 Respostas
+ 7
If order doesn't matter, this also works
https://code.sololearn.com/c238ZlptsJKU/?ref=app
+ 5
If you don't know Python functions, there is always a more fundamental way suitable for all languages
https://code.sololearn.com/cW04Fs3X8EJS/?ref=app
+ 5
also Counter is pythonic.
https://code.sololearn.com/cPVvRkAigm8d/?ref=app
+ 4
Ipang WhyFry Mirielleđœ Gordon
that makes a nice collection for solutions of a common task.
will keep that post in my notebookđ€
+ 3
You're welcome priya krishnan ,
Please mark the answer that came earliest, my response was an additional example only đ
+ 2
Thank u WhyFry
+ 2
Thank u Ipang
+ 2
Mirielleđœ
I still don't quite understand how 'zip' works, but good job nonetheless ... đđ
0
Hello
0
I am help you
0
Hello