为什么第一个循环首先生成预期结果,但第二个循环生成空列表的同一个循环?
y = ["I am ok", "We are there", "Contraction: I've I'm won't"]
y1 = [(word for word in text.split(" ")) for text in y]
print("First:\n")
for i in y1:
print(list(i))
print("\nSecond:\n")
for i in y1:
print(list(i))
结果:
First:
['I', 'am', 'ok']
['We', 'are', 'there']
['Contraction:', "I've", "I'm", "won't"]
Second:
[]
[]
[]