I want to iterate through list of list. To iterate through every list inside list also.
list=[[0.9 0.8 0.1 0.2 0.5 ][0.5 0.3 0.2 0.1 0.7 ][0.6 0.1 0.3 0.2 0.9][0.3 0.7 0.4 0.1 0.8]]
Thus to iterate through every list inside, only to the third position, eg:
list=[[0.9 0.8 0.1][0.5 0.3 0.2][0.6 0.1 0.3][0.3 0.7 0.4 ]]
Somebody tell me, how can do this? This is my code:
list=[]
i=0
j=0
data=open('BDtxt.txt','r')
for line in data.xreadlines():
lista.append(line.strip().split())
while i<len(lista):
while j < len(lista[i]):
print lista[j]
j+=1
i+=1
and the output is:
['0.9', '0.8', '0.1', '0.2', '0.5']
['0.5', '0.3', '0.2', '0.1', '0.7']
['0.6', '0.1', '0.3', '0.2', '0.9']
['0.3', '0.7', '0.4', '0.1', '0.8']
and I want the output to be
[0.9 0.8 0.1]
[0.5 0.3 0.2]
[0.6 0.1 0.3]
[0.3 0.7 0.4]