#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    1
    Rep Power
    0

    Manipulating lists


    I have a list:

    [(12,12),(1,23),(43,12)]

    I also have another list:

    ['12 12 0 8 0.23','54 34 0 8 0.23','12 2 0 8 0.23']

    How can check to see if the elements in the first list are in the other list so the list then becomes

    ['12 12 0 8 0.23']

    stringcontacts = [str(x) for x in contacts]
    stringcontacts = [x.replace("(","") for x in stringcontacts]
    stringcontacts = [x.replace(")","") for x in stringcontacts]
    stringcontacts = [x.replace(","," ") for x in stringcontacts]

    I have done this code which makes the 1st array similar :

    ['12 12','54 34' '12 2']

    Is there anyway to make this more efficient
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,904
    Rep Power
    481
    I don't comprehend your question.
    An equality test needn't use a specific data type.
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo