Python Forum
Searche each element of each tuple based 3 numbes
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Searche each element of each tuple based 3 numbes
#1
Hi.
I have combinations based list with tuple nested
How to find based 3 numbers of my choice if all this 3 numbes is inside of list of tups?

import itertools

all_num = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
*res, = itertools.combinations(all_num,6)
look_up_numbs = (17,19,20) >>> lookup for this numbers inside of each tuples
(Any_number,Any_number,Any_number,17,19,20)
it doens't metter the position of elements if all three [look_up_numbs] is inside any of tuples

(13, 14, 15, 17, 18, 20) > No return, it's wrong (miss 19)
(13, 14, 15, 17, 19, 20) > OK, correct
(13, 14, 15, 18, 19, 20) > No return, it's wrong (miss 17)
(13, 14, 16, 17, 18, 20) > No return, it's wrong (miss 19)
(17, 18, 19, 20, 25, 26) > OK, correct
Reply


Messages In This Thread
Searche each element of each tuple based 3 numbes - by zinho - Dec-09-2023, 11:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  code with no tuple gets : IndexError: tuple index out of range Aggam 4 4,504 Nov-04-2020, 11:26 AM
Last Post: Aggam
  How to get first line of a tuple and the third item in its tuple. Need Help, Anybody? SukhmeetSingh 5 4,397 May-21-2019, 11:39 AM
Last Post: avorane
  Unable to locate element no such element gahhon 6 5,757 Feb-18-2019, 02:09 PM
Last Post: gahhon
  Converting List of 3 Element Tuple to Dictionary fooikonomou 11 7,821 Jan-14-2019, 09:51 AM
Last Post: perfringo
  Newbie question for sum the specific element in named tuple zydjohn 1 4,956 Dec-12-2017, 07:29 PM
Last Post: buran
  Change single element in 2D list changes every 1D element AceScottie 9 14,332 Nov-13-2017, 07:05 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