Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7538407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:06:50+00:00 2026-05-30T07:06:50+00:00

I have one reference list, such as : dico = [ ‘test’, ‘blabla’ ]

  • 0

I have one reference list, such as :

dico = [ 'test', 'blabla' ]

And I would like to remove these items that are contains in an other list :

listTest = [ 'S01_test', 'S02_ahah', 'S03_blabla' ]

The result should be :

[ 'S02_ahah' ]

I try to use sets, but with no success. Any ideas ?

Thank you 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:06:51+00:00Added an answer on May 30, 2026 at 7:06 am

    You can do this with a list comprehension:

    >>> [x for x in listTest if x.split('_')[1] not in dico]
    ['S02_ahah']
    

    Or with filter():

    >>> dico = [ 'test', 'blabla' ]
    >>> listTest = [ 'S01_test', 'S02_ahah', 'S03_blabla' ]
    >>> filter(lambda x: x.split('_')[1] not in dico, listTest)
    ['S02_ahah']
    

    If you are on python-3.x remember to wrap filter() with list() since it returns an iterator:

    >>> f = filter(lambda x: x.split('_')[1] not in dico, listTest)
    >>> list(f)
    ['S02_ahah']
    

    I would have probably prefer the use of filter() with a lambda over the list comprhension, but from a very basic timing the comprehension seems to be faster.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one std::list<> container and these threads: One writer thread which adds elements
I would like to have a map data type for one of my entity
I have a javascript function (class) that takes a function reference as one paremter.
I have one field that I need to sum lets say named items However
I have a list of recipes obtained from a database that looks like this:
I have one table Books, with a column genres where I want to reference
I have a list of menu items and content in a single page. In
Using a reference from... http://weblogs.asp.net/pwelter34/archive/2006/05/03/444961.aspx I have a serializable generic dictionary. One thing I
I have two references to a SQLite assembly, one for 32-bit and one for
Does any one have a preference on how to check if a value is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.