current position:Home>How can Python write here to become a variable

How can Python write here to become a variable

2022-02-02 19:04:56 CSDN Q & A

img


Namely new_type Where? ,car1 It's a list , How to traverse




Refer to the answer 1:

new_type It's a variable , It is assigned by input statement . By traversing cars Just modify it . Example :

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)



Refer to the answer 2:



Refer to the answer 3:

Direct use new_type That's it .
for The loop will automatically take each element of the list to new_type Variable




Refer to the answer 4:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202021904545106.html

Random recommended