Python数列中元素的修改
- 添加元素
– list.append()
— 无需定义数列长度
name = []
key = True
while key:
thing = input('Please enter a thing,press q to quit')
name.append(thing)
if thing == 'q':
key = False
print(name)
– list[i] = input(’ ')
—通过元素赋值来添加元素
bicycles = [0]*5
for i in range(5):
bicycles[i]=input('Please enter a thing,press q to quit')
print(bicycles)<