Skip to content
Advertisement

Tag: list

All possible combinations of a list of tuples

I’m creating “Boggle” in python, and I have a list of tuples that represent coordinates on a game board: I’m trying to create a new list of lists of tuples that will represent all possible paths on the board. It’d look something like this: I tried using itertools.combinations and itertools.permutations but it doesn’t seem to do the job, for example

How do I find the index of an unknown value in python?

So basically I have a list like this – and I don’t know what val is. So how do I get the index of val (3) only knowing that it is not None Answer This one line solution gives you the first value that is not None. This returns the actual value, to get the index, look into this answer

Create a Nested list from a pandas data frame

I am trying to create a kind of nested list from a pandas data frame. I have this data frame: So I want to create a kind of nested list using the above data frame using ‘id1’ column, and ‘Name1’ and ‘Name2’ columns. For example, if we think about the first row, id1 should be in one list ([‘ab-85643’]) and

Advertisement