How are we doing? Please help us improve Stack Overflow. Take our short survey

Questions tagged [tuples]

In programming, tuples are simple *product types*, representing ordered collections of types.

0 votes
0 answers
15 views

Sorting in a list with tuples with second element in a tuple [duplicate]

I have a code: scores_list_ind = list(enumerate(scores_list, 1)) and I have output: [(1, 3), (2, 5), (3, 7), (4, 4), (5, 8), (6, 7)] I tried to use sorted() and it sorted me to this: [(6, 7), (5, 8),...
user avatar
1 vote
2 answers
29 views

Check if at least one tuple is present in a string

I have a list of tuple. I want to check if both the tuple elements are present in a string. I came up with this code. def check_if_present(user_name): is_present = False tuple_list = [('...
user avatar
  • 318
1 vote
2 answers
36 views

Flatten a list inside list of tuples

I have the following list of tuples. lst = [ ('LexisNexis', ['IT Services and IT Consulting ', ' New York City, NY']), ('AbacusNext', ['IT Services and IT Consulting ', ' La Jolla,...
user avatar
  • 1,067
-1 votes
1 answer
9 views

Combining Tuples into a List

I have a list of tuples: [(1,2),(5,10),(2,5)] How to get [1,2,5,10]
user avatar
  • 35
1 vote
1 answer
30 views

sorting a list of tuple by second element but if the second element of mutiple tuple matches then sort using the first element

Given a list of tuples where first and second elements are integer. Sort them using the second element but if the second element matches sort them using first element. Basically, I am trying to ...
user avatar
  • 108
0 votes
1 answer
46 views

how to merge list of tuples and a list of unequal length?

list_1 = ['amt_doc_post','grn_std_qty_kg','po_gross_value','po_num_count','po_qty'] list_2 = [('lag_3', 'lag_3', 'lag_3', 'lag_3', 'lag_3'), ('lag_3', 'lag_3', 'lag_3', 'lag_3', 'lag_4'), ('lag_3', '...
user avatar
0 votes
0 answers
56 views

Extracting time difference and then summing them up with gmtime()

I'm trying to find ways to calculate the difference of time measurements taken at different intervals, and then sum them up. Since datetime is not available in MicroPython, I tried gmtime() function ...
user avatar
0 votes
1 answer
23 views

Typescript does not recognize interface function expression tuples

I'm trying to call a function expression like this: export default interface IUserManager { deleteUser: ((userId: string) => Promise<void>) | ((userName: string, userSurname: string, city:...
user avatar
0 votes
0 answers
18 views

TypeError: tuple indices must be integers or slices, not list, PCA function

def pca(self,message): X=self.getData(False) pca = PCA(n_components=2) df=pca.fit(X[message]) component_names = [f"PC{i+1}" for i in range(df.shape[1])] ...
user avatar
1 vote
3 answers
33 views

How to match multiple enum cases in switch-statement on tuple?

I have a switch statement that check a tuple. One of the part of the tuple is an enum. How can I match multiple enum cases inside that tuple? I've tried several things, which all lead to compiler ...
user avatar
1 vote
1 answer
22 views

"transform apply" - using tuple elements as parameters to one function to construct a parameter pack for another

Given the following: constexpr auto t = std::make_tuple(3, 2, 1); template<auto x> auto InnerF() {return -x;} auto OuterF(auto... args) {return (args + ...);} I can use the elements of t as ...
user avatar
1 vote
0 answers
17 views

Java Vavr pattern matching on tuple using wild card

I'm using Vavr to do pattern matching on a vavr-tuple but I can't seem to do get the pattern matching to work in tuple. Here is my code Tuple2 test = Tuple.of("foo", "bar"); ...
user avatar
-1 votes
1 answer
29 views

Grabbing all values from list in the second index?

I have a list of size 1141 called lst containing float numbers (decimal numbers). There are 2 indices at each point in the list such that if I call the second index at any of the 1141 points i.e) ...
user avatar
0 votes
1 answer
16 views

How do I retrieve pair combinations from a list of pairs without any single element being in more than one pair?

If I have a list of pairs, such as [(egg,man),(egg,dog),(cat,cactus),(cactus,elephant),(giraffe,chocolate),(tea,boat),(sky,lizard),(sky,tree),(helicopter,lizard)] How would I retrieve the most amount ...
user avatar
2 votes
1 answer
33 views

How do I compare two lists of pairs to see which pair combinations exist in both? [closed]

Here is a simple example of what I am trying to do. So with two lists of pairs, such as: pairs1 = [(egg,dog),(apple,banana),(orange,chocolate),(elephant,gargoyle),(cat,lizard)] pairs2 = [(cat,lizard),(...
user avatar

15 30 50 per page
1
2 3 4 5
753