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 6099683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:18:03+00:00 2026-05-23T13:18:03+00:00

I got two different lists (let’s call them A and B) of lists and

  • 0

I got two different lists (let’s call them A and B) of lists and I have to find the elements that are in B and not in A and viceversa. The lists inside the two main lists can be unordered and they basically contains strings. I’m looking for a code or an hint to solve this problem.

EDIT: I didn’t post the code because it was a lot stupid. However as requested, the code I tried:

for elem in list0:
    if not (elem in list1):
        for d in list1:
           if not (d in list0):
               /*stuff I got to do on the elements*/

EDIT2: test case:

A = [[a, b, c], [d, e, f]]
B = [[b, a, c], [a, o, p]]

I want to exec funct(A, B) and get as return value C = [[a, o, p]]. I also need the viceversa, D = [d, e, f].

  • 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-23T13:18:03+00:00Added an answer on May 23, 2026 at 1:18 pm

    If you input data is list of list of strings then you can use something like this:

    diff = lambda a,b: [x for x in a if x not in b]
    
    mergelist = lambda lVals: reduce(lambda res,x: res + x, map(tuple, lVals))
    
    diff(mergelist(A), mergelist(B))
    diff(mergelist(B), mergelist(A))
    

    EDITED as per comment:

    mergelist = lambda lVals: reduce(lambda res,x: res + x, map(tuple, lVals))
    diff = set(a) ^ set(b) # would contains difference between two initial lists 
    

    EDITED:

    A = [['a', 'b','c'], ['d','e', 'f']]
    B = [['b', 'a', 'c'], ['a', 'o', 'p']]
    
    diff = lambda a,b: [list(x) for x in map(tuple, map(sorted, a)) if x not in map(tuple, map(sorted, b))]
    print diff(A, B)
    print diff(B, A)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a table recording views of programs. Each program can have two different
Working in Python 2.7. I have two different lists, A and B (simplified to
I have two comboBoxes, one that lists the 7 days of the week and
I've got two small structural issues that I'm not sure how to handle given
I've got two ASP.Net applications residing in two different folders on my server: /Foo
I've got a scenario where I want to switch on two different tables in
I'm in need of help - I've got two mysql databases on different servers
I got two tables in my database: user and call. User exists of 3
I want to generate a DataTables out of Lists. so f.e. I got two
I've got two different exports of our CVS repository into git. They diverge at

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.