Girish Sahani wrote:
> 1) A dictionary with the numbers as keys and the letters as values.
> e.g the above would give me a dictionary like
> {1:'a', 2:'b', 3:'a', 5:'c', 6:'c' ........}

def get_dict( f ) :
    out = {}
    for line in file(f) :
        n1,s1,n2,s2 = line.split(',')
        out.update( { int(n1):s1[1], int(n2):s2[1] } )
    return out

> 2) A list containing pairs of numbers from each line.
> The above formmat would give me the list as
> [[1,2],[3,5],[3,6][3,7][8,7]......]

def get_pairs( f ) :
    out = []
    for line in file(f) :
        n1,_,n2,_ = line.split(',')
        out.append( [int(n1),int(n2)] )
    return out

Regards
Sreeram

Attachment: signature.asc
Description: OpenPGP digital signature

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to