Help me!!

beginner zyzhu2000 at gmail.com
Thu Aug 16 21:28:03 CEST 2007


On Aug 16, 2:26 pm, beginner <zyzhu2... at gmail.com> wrote:
> > Some one help me so that
> > If ab = [a,b,c,d]
> > and cd = [a,c]
> > my global list file should be [A,b,C,d]

If there is a lot of entries in the list, I would consider using an
indexed data structure such as dict.


ab=['a','b','c','d']
cd=['a','c']
common=[x.upper() for x in ab if x in cd]
ab_minus_cd=[x for x in ab if x not in cd]
cd_minus_ab=[x for x in ab if x not in cd]
requested_list = common+ab_minus_cd+cd_minus_ab- Hide quoted text -




More information about the Python-list mailing list