我有一个教程中的代码可以做到这一点:
elements = []
for i in range(0, 6):
print "Adding %d to the list." % i
# append is a function that lists understand
elements.append(i)
for i in elements:
print "Element was: %d" % i
但是,如果我只想从元素 [0] 打印到元素 [4],这是如何实现的?