是否可以遍历列表列表并打印出列表的名称以及它们的内容?

Is it possible to iterate over a list of lists and print out the name of the lists in addition to their contents?

我正在尝试在我的嵌套列表中打印出其两个相应值旁边的股票代码。

gme_infos = [45.95, 133.46]        # Number of shares, Cost basis
amc_infos = [49, 32.24]            # Number of shares, Cost basis
list_infos = [gme_infos,amc_infos]

for i in list_infos
     print(i)

到目前为止我的输出是你所期望的

[45.95, 133.46]
[49, 32.24]

我该怎么做才能让打印的值出现在它们源自的列表旁边,但作为迭代的一部分?

gme_infos [45.95, 133.46]
amc_infos [49, 32.24]

使 list_infos 成为字典,而不是列表。

list_infos = {'gme_infos': gme_infos, 'amc_infos': amc_infos}
for name, infos in list_infos.items():
    print(f"{name} {infos}")