0

I have a nested list where 2 lists are included in the main list. The 2nd list has no items lets say A = [[3,4,5,1,6,],[]]

I want to separate the 1st list into tuples in a way that it gives the following output: output >> (3,4),(4,5),(5,1),(1,6)

Can you please help me with this??

1 Answers1

0

Try this:

result = [(A[0][i],A[0][i+1]) for i in range(len(A[0])-1)]

output:

[(3, 4), (4, 5), (5, 1), (1, 6)]
Taohidul Islam
  • 5,246
  • 3
  • 26
  • 39