Python这里怎么写才能成为一个变量

img


就是new_type那里,car1是一个列表,怎样遍历

new_type就是变量,是通过输入语句赋值的。通过遍历cars进行修改就行了。示例:

a=input('1.modify\n2.remove\n3.return\n')
cars=['a','a01','2019']
if a=='1':
    t=input('new type:')
    n=input('new number:')
    tm=input('new time:')
    for car in cars:
        cars[0]=t
        cars[1]=n
        cars[2]=tm
    print(cars)

直接用new_type就可以了啊。
for循环会自动取出列表的每个元素到new_type变量