Python Forum
which sequence is in a sequence
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
which sequence is in a sequence
#2
You want to use set().

list1 = [1,1,1,2,3,4,5]
list1 = set(list1) # unique elements
list2 = [4,2,5,1,6,7,4]
list2 = set(list2) # unique elements
print(list1 & list2)
https://docs.python.org/3/tutorial/datastructures.html#sets
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Messages In This Thread
which sequence is in a sequence - by Skaperen - May-27-2018, 01:43 AM
RE: which sequence is in a sequence - by DeaD_EyE - May-27-2018, 09:46 AM
RE: which sequence is in a sequence - by Skaperen - May-28-2018, 01:27 AM
RE: which sequence is in a sequence - by killerrex - May-27-2018, 10:11 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Warning - ' invalid escape sequence '\s'' tester_V 4 32,420 Aug-08-2024, 04:58 PM
Last Post: tester_V
  how to test if something is a sequence? Skaperen 11 4,344 Jul-24-2024, 03:41 AM
Last Post: Skaperen
  which exception should be thrown for a sequence of the wrong length? Skaperen 1 1,576 Jan-06-2023, 04:13 AM
Last Post: deanhystad
  (off) and (on) sequence AlexPython 6 2,344 Dec-05-2022, 07:25 PM
Last Post: AlexPython
  How to set a sequence of midi note on and note off values in ticks tomharvey 2 3,870 Mar-25-2022, 02:33 AM
Last Post: tomharvey
  TypeError: sequence item 0: expected str instance, float found Error Query eddywinch82 1 7,254 Sep-04-2021, 09:16 PM
Last Post: eddywinch82
  Why can't I explicitly call __bool__() on sequence type? quazirfan 11 7,096 Aug-20-2021, 06:49 AM
Last Post: Gribouillis
  Error : "can't multiply sequence by non-int of type 'float' " Ala 3 4,050 Apr-13-2021, 10:33 AM
Last Post: deanhystad
  Python - Import file sequence into Media Pool jensenni 1 2,946 Feb-02-2021, 05:11 PM
Last Post: buran
  How can I found how many numbers are there in a Collatz Sequence that I found? cananb 2 3,458 Nov-23-2020, 05:15 PM
Last Post: cananb

Forum Jump:

User Panel Messages

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