I need to swap list (as I am importing nested list from given input file). Next I need to swap every sub-list for every iteration of loop. The sub-list should be on first position.
I wrote the code but instead of swapping it copying the multiple list:
import numpy as np
fd =open('circle_input.txt','r')
d=np.loadtxt(fd,delimiter=',',dtype={'names':
('co1','col2','col3'),'formats':('float','float','float')})
temp1=d
temp2=d
for i in range(len(d)):
temp1[0]=temp1[i]
temp1[i]=temp2[0]
print(temp1)
circle_input.txt
0,0,5
10,0,5
0,10,5
-10,0,5
0,-10,5
Copying of list1 to list2 can be done using
list2=list1[:]Not by:-
list2=list1where
list1andlist2are list not list of lists