I have this list and a start point as below:
lst = [[0, 1], [0, 4], [3, 4], [5, 1], [5, 2]]
point = 3
I want to write a function that gives me this list in return: [3,4,0,1,5,2]
. It takes start point, finds the pair containing the start point and takes its other half as the new start point.
Given list is an example, length of the list is not specified.
I tried to write a for
function but, since the length of the list is not constant, it doesn't give the correct output
What I tried:
def func(start,lst):
for i in range(len(lst)):
if lst[i][1]==start:
cont==lst[i][0]
lst2=lst.remove(lst[i])
if lst[i][0]==start:
cont==lst[i][1]
lst2=lst.remove(lst[i])
func(cont,lst2)