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.)
>>> 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
Post a Comment