Merging ordered lists

Méta-MCI (MVP) enleverlesX.XmcX at XmclaveauX.com
Sun Jun 1 10:46:24 CEST 2008


Hi!

Use set (union).
Example:

    la=[2,1,3,5,4,6]
    lb=[2,8,6,4,12]

    #compact:
    print list(set(la).union(set(lb)))

    #detail:
    s1 = set(la)
    s2 = set(lb)
    s3 = s1.union(s2)
    print list(s3)


@-salutations

Michel Claveau




More information about the Python-list mailing list