相同的循环会产生不同的结果

时间:2018-06-01 12:42:14

标签: python python-3.x

为什么第一个循环首先生成预期结果,但第二个循环生成空列表的同一个循环?

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:
[]
[]
[]

0 个答案:

没有答案