We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Collections
- Company Logo
- Discussions
Company Logo
Company Logo
Sort by
recency
|
1293 Discussions
|
Please Login in order to post a comment
First time using lambda expression to sort a dictionnary.
Find my code below.
The logic is to use collections.Counter to count every letter of the company name. Then sort them firstly by the occurence, then alphabetically.
At the beginning, I've started by using the most_common() function of Counter, but it was quite difficult to implement it in a lambda expression for me. But As I said, it was my first time with lambda expression. So if you have some advices, I am open.
Here my code :
if name == 'main': s = input() char_count = {}
hi guies can use: