Monday, 15 February 2010

python - compare 3 lists and delete all matched elements -



python - compare 3 lists and delete all matched elements -

hy,

i want compare 3 lists , whenever match occurs, elements of lists deleted.

( --> every time gpos = g00 , xpos = 0 , ypos = 0 )

gpos = ['g01','g01','g00','g00','g00','g00','g00','g00','g00','g00'] xpos = ['249','248', '0' , '0' , '72', '0' , '66','67' ,'81' , '82'] ypos = ['18', '28' , '0' , '0' , '52', '0', '53','55' ,'54' , '52'] --------------------- output should be: --------------------- gpos = ['g01','g01','g00',g00','g00','g00','g00'] xpos = ['249','248', '72','66','67' ,'81' , '82'] ypos = ['18', '28' , '52','53','55' ,'54' , '52']

i have no thought o_o

this rather crude, work.

for index,element in enumerate(xpos): if element == '0': if ypos[index] == '0': if gpos[index] == 'g00': del gpos[index] del xpos[index] del ypos[index]

just add together this, should have atleast tried , set question. doesn't matter how much wrong are, should seek best code on own.

python python-3.x

No comments:

Post a Comment