我正在尝试创建一个列表列表,它基于受多个循环影响的多个输入。你知道吗
第一个循环将是:
(在数组中找到的基金数)
第二个循环将是:
查找基金名称(由第一个输入定义)(1000行x 7列的数组的第0列),如果在数组的第0列上找到输入,则为该行的其余部分创建一个列表,依此类推,以获得所有所需的输入。你知道吗
到目前为止,这是我所做的,但没有设法记录个人名单发现,它只返回最后一个。你知道吗
有人能帮忙吗?你知道吗
#load file
from csv import reader
archivo=open ('book5.csv')
leemos=reader(archivo)
matriz= list(leemos)
#input hnumber of funds to look for
n_fondos=int(input('NUMERO DE FONDOS: ?'))
#create the list based on the number of funds selected above
for a in range(n_fondos):
fondos=[]
new_list=[fondos for a in range (n_fondos)]
while fondos==[]:
n_corto=input(str('INTRODUZCA NOMBRE CORTO: ?'))
for fila in matriz[1:]:
valor=fila[0]
valor2=fila[1:6]
if valor==n_corto:
fondos.append(valor2)
#print the new list with all the diferent funds found
print(new_list)
If I input 2 and type to funds to be found it return a list of 2 funds, but just the last one I introduced.
目前没有回答
相关问题 更多 >
编程相关推荐