在Python中,我如何从列表中提取列表元素并创建另一个列表。所以,我想从这里获取:
all_list = [['1 2 3 4','2 3 4 5'],['2 4 4 5', '3 4 5 5' ]]
一个类似这样的新列表:
list_of_lists = [[('3','4'),('4','5')], [('4','5'),('5','5')]]
以下是我所做的,但它不起作用。
for i in xrange(len(all_lists)):
newlist=[]
for l in all_lists[i]:
mylist = l.split()
score1 = float(mylist[2])
score2 = mylist[3]
temp_list = (score1, score2)
newlist.append(temp_list)
list_of_lists.append(newlist)
请帮忙。非常感谢您的帮助。