Jul-25-2019, 03:26 PM
How to print counter without bracket and sort result in python ?
I need to have this final result :
I need to have this final result :
2 : 2 3 : 3 4 : 4 5 : 3 7 : 2But I'v got this :
Counter({4: 4, 3: 3, 5: 3, 2: 2, 7: 2})Here is my code :counter=collections.Counter(lst)
print(counter)
counter.keys()
for key, value in counter.items():
#print(key,":", value)
ctx = (key, value)
print(ctx)
tab.append(ctx)
tab.sort()
#print(tab)
#print(*tab, sep = "\n")Or this result but not sorted with this print options :print(key,":", value)
3 : 3 4 : 4 2 : 2 5 : 3 7 : 2Thanks for any help.
