Here is the code in python, this code arranges the alphabets in descending 
order and now I want to encode each alphabet with 0 and next alphabet with 1, 
then 00,01,10,11,000,001 and so on. Please help me with that.

//////////////////////////////////////////////////////////
//////////////////CODE////////////////////////

from collections import defaultdict
import string
text ='intalks is an organization comprised of passionate 
students'.lower().translate(None,string.punctuation+' ')
c = defaultdict(int)
c.update({letter:0 for letter in string.lowercase[:26]}) 
for letter in text:
        c[letter] += 1


for letter,freq in sorted(c.iteritems(),key=lambda (l,f): (-f,l)): 
        print freq, letter
        
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to