python find all combinations of a list code example

python find all combinations of a list

1

1 Example

0
my_list = ["python", [15, 12, 33, 14], "is", ["fun", "easy", "better", "cool"]]

print("The list is :")
print(my_list)

K = 4
print("The value of K is :")
print(K)

my_result = []
count = 0
while count <= K - 1:
   temp = []

   for index in my_list:

      if not isinstance(index, list):
         temp.append(index)
      else:
         temp.append(index[count])
   count += 1
   my_result.append(temp)

print("The result is :")
print(my_result)

Other Code Examples