Reputation: 1083
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.
Many thanks!
Upvotes: 0
Views: 335
Reputation: 253
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.
Upvotes: 3