简体   繁体   中英

How do I change the current line when debugging Python on Visual Studio Code?

How do I change the current line? For example, if after assign a value to a variable I want to go back and assign a new value?

myList = [1, 8, 9, 5, 2]

a = 3

for item in myList:
    print(item * a)

On this snippet for example, if after multiply the first element of my list I decide change the value of a = 3 to a = 8 , how do I go back and do it?

I am trying to drag the cursor but it is not working. I do it when debugging VBA on Excel so I would like to do the same in Visual Studio Code when debugging Python.

更改<code> a </ code>值

Many thanks!

Do you mean like this?

myList = [1, 8, 9, 5, 2]

a = 3

for index, item, in enumerate (myList):
    if index == 0: 
        a = 8
    else: 
        a = 3
    print(item * a)

I have casted it as an enumerate, and then i have used an if else to check the value of a.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM