我对 python 中的列表以及如何从列表中打印有疑问。以下哪个代码片段打印了列表“单词”中的所有 7 个单词?我已经编译并尝试过,但我仍然不知道哪些片段是正确的。
1.
i = 0
while i < 7:
print(words[i], end=" ")
i += 1
2.
i = 0
while i < 7:
print(words[i], end=" ")
i += 1
3.
i = 1
while i < 7:
print(words[i], end=" ")
i += 1
4.
i = 0
sum = ""
while i < 7:
sum += words[i]
i += 1
print(sum)
5.
i = 0
sum = ""
while i <= 7:
sum += words[i]
i += 1
print(sum)