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
#5
I got help on other site but I wanted to share the solution just in case anyone else has the same problem.

list1 = [['orange', [1, 2, 3]]]
list2 = [['apple', [1, 2, 3]], ['banana', [1, 2, 3]], ['pear', [-1, 2, 3]], ['kiwi', [1, -2, 3]]]

y = [x for x in list2 if x[1][0] not in [a[1][0] for a in list1]]
print(y)
Reply


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

Possibly Related Threads…
Thread Author Replies Views Last Post
  Eight Queens Problem, error in printing list snl_9527 8 425 Yesterday, 11:48 AM
Last Post: Gribouillis
  how to get qualified objects in a list Azdaghost 5 520 Apr-22-2025, 06:03 PM
Last Post: Azdaghost
  Basic list question sanora600 2 503 Apr-13-2025, 07:07 AM
Last Post: noisefloor
  Entry field random pull from list, each return own line Bear1981 6 832 Feb-25-2025, 06:09 AM
Last Post: Pedroski55
  removing one list element without using its index paul18fr 7 1,207 Feb-22-2025, 07:59 PM
Last Post: DeaD_EyE
  question about changing the string value of a list element jacksfrustration 4 2,167 Feb-08-2025, 07:43 AM
Last Post: jacksfrustration
  knowing for loop position in a list medic5678 4 722 Jan-31-2025, 04:19 PM
Last Post: perfringo
  help to parser arguments list absolut 3 695 Jan-15-2025, 03:19 AM
Last Post: BashBedlam
  Get an FFMpeg pass to subprocess.PIPE to treat list as text file? haihal 2 1,072 Nov-21-2024, 11:48 PM
Last Post: haihal
  List comprehension not working right Cris9855 3 969 Nov-04-2024, 03:46 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

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