food = ['a' , 'b' , 'c']
for pizza in food :
print(pizza)
print("i really like pizza!")
a
b
c
i really like pizza!
[Finished in 0.9s]
#4-6:本题主要考察的是range()函数的步长问题,可以制定一个步长在使用的过程中
numbers = list(range(1,20,2))
print(numbers)
[1, 3, 5, 7, 9, 11, 13, 15, 17, 19]
[Finished in 0.8s]
ans = [value**3 for value in range(1,10)]
print(ans)
[1, 8, 27, 64, 125, 216, 343, 512, 729]
[Finished in 0.9s]
还有一个非常重要的列表复制
lista = listb不等于复制了,而只是lista只是listb的一个别名
应该是lista = listb[:]