if statement - Printing only most frequency uppercase letter, digits python -


i had open text file , find frequency of characters using dictionary, managed dictionary letters & frequency , digit & frequency. thing have print frequency used upppercase letter frequency , frequency digit frequency. tried every if statement seems not work.

ex: dictionary = {l:1, b: 6, a:5, 2:1, 5:3} prints("most used uppercase letter is: , used 5 times.)

use filter , max:

>>> d = {'l':1, 'b': 6, 'a':5, '2':1, '5':3} >>> digit = max(filter(str.isdigit, d), key=d.get) >>> digit, d[digit] ('5', 3) >>> upper = max(filter(str.isupper, d), key=d.get) >>> upper, d[upper] ('a', 5) 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -