Python Forum
Use one list as search key for another list with sublist of list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Use one list as search key for another list with sublist of list
#4
I tried disecting it but is not taking me far since eventhough it is returning the difference, the result is not "filling back" to what list it belongs, which should return
['pear', [-1, 2, 3]]
list1 = [['orange', [1, 2, 3]]]
list2 = [['apple', [1, 2, 3]], ['banana', [1, 2, 3]], ['pear', [-1, 2, 3]], ['kiwi', [1, -2, 3]]]

S = set(tuple(x[1]) for x in list1)

a = [x[1][0] for x in list1]

b = [x[1][0] for x in list2]

z = [x for x in b if x not in a]
print(z)
Reply


Messages In This Thread
RE: Use one list as search key for another list with sublist of list - by jc4d - Jan-11-2022, 10:37 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  sort list of dictionaries by value jacksfrustration 4 264 Jun-21-2024, 08:44 PM
Last Post: deanhystad
  List with equal repeatable data Ataman 6 349 Jun-13-2024, 07:30 PM
Last Post: Ataman
  Downloading Page Source From URL List zunebuggy 11 581 Jun-08-2024, 06:40 AM
Last Post: Pedroski55
  how to capitalize letter in list object Python iwonkawa 4 316 May-29-2024, 04:29 PM
Last Post: DeaD_EyE
  remove duplicates from dicts with list values wardancer84 27 1,228 May-27-2024, 04:54 PM
Last Post: wardancer84
  what to return for an empty list Skaperen 2 324 May-24-2024, 05:17 PM
Last Post: Skaperen
  Extending list doesn't work as expected mmhmjanssen 2 365 May-09-2024, 05:39 PM
Last Post: Pedroski55
  Strange behavior list of list mmhmjanssen 3 525 May-09-2024, 11:32 AM
Last Post: mmhmjanssen
  Sort a list of dictionaries by the only dictionary key Calab 2 782 Apr-29-2024, 04:38 PM
Last Post: Calab
  element in list detection problem jacksfrustration 5 672 Apr-11-2024, 05:44 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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