Python Forum
Find Common Elements in 2 list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Find Common Elements in 2 list
#5
(Apr-14-2021, 03:29 PM)klllmmm Wrote: Hope this helps
A = [(7.5,), (17.5,), (22.5,), (25.0,), (27.5,), (30.0,), (37.5,), (40.0,)]
B = [(17.5,), (22.5,), (25.0,), (27.5,), (30.0,), (37.5,), (40.0,), (42.5,)]

list(set(A).intersection(B))
Output:
[(37.5,), (40.0,), (30.0,), (27.5,), (17.5,), (25.0,), (22.5,)]
It is ok now
THanks!
klllmmm likes this post
Reply


Messages In This Thread
Find Common Elements in 2 list - by quest - Apr-14-2021, 03:17 PM
RE: Find Common Elements in 2 list - by klllmmm - Apr-14-2021, 03:29 PM
RE: Find Common Elements in 2 list - by quest - Apr-14-2021, 03:33 PM
RE: Find Common Elements in 2 list - by quest - Apr-14-2021, 03:57 PM
RE: Find Common Elements in 2 list - by Larz60+ - Apr-14-2021, 03:31 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  unable to remove all elements from list based on a condition sg_python 3 377 Jan-27-2024, 04:03 PM
Last Post: deanhystad
Question mypy unable to analyse types of tuple elements in a list comprehension tomciodev 1 427 Oct-17-2023, 09:46 AM
Last Post: tomciodev
  Program to find Mode of a list PythonBoy 6 1,000 Sep-12-2023, 09:31 AM
Last Post: PythonBoy
  find random numbers that are = to the first 2 number of a list. Frankduc 23 3,016 Apr-05-2023, 07:36 PM
Last Post: Frankduc
  Checking if a string contains all or any elements of a list k1llcod3 1 1,023 Jan-29-2023, 04:34 AM
Last Post: deanhystad
  Find (each) element from a list in a file tester_V 3 1,157 Nov-15-2022, 08:40 PM
Last Post: tester_V
  How to change the datatype of list elements? mHosseinDS86 9 1,910 Aug-24-2022, 05:26 PM
Last Post: deanhystad
  read a text file, find all integers, append to list oldtrafford 12 3,372 Aug-11-2022, 08:23 AM
Last Post: Pedroski55
  find some word in text list file and a bit change to them RolanRoll 3 1,482 Jun-27-2022, 01:36 AM
Last Post: RolanRoll
  How to find the second lowest element in the list? Anonymous 3 1,907 May-31-2022, 01:58 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020