For example,
def power(x, n):
res = 1
for i in range(n):
res *= x
return res
power('10',5)
Then, it will raise the error as follows.
TypeError: can't multiply sequence by non-int of type 'str'
Now, I try to use %debug
in the new notebook cell to debug.
ipdb> x = int(10)
ipdb> c
However, in %debug
, if I use c
which means continue
in ipdb
, it can't continue to run with changed value x
.
So, I wonder if there is any method to correct the value of a variable while debugging and continue to run.
Update:
This is just an example.
In fact, I want to run the code for a long time in some cases, and an error occurs midway. I want to correct the error and try to continue to run the code. You know, simply re-running can take a long time.