I'm trying to debug a code snippet includes list comprehension inside loop.
list_a = ['a', 'b', 'c']
list_b = ['a', 'b']
for x in list_a:
print([i for i in list_b if i == x])
The code run okay when I run the entire script. However when I located a breakpoint before the for loop and try to run the for loop interactively I got the following error:
Traceback (most recent call last): File "/root/pycharm/helpers/pydev/_pydevd_bundle/pydevd_exec2.py", line 3, in Exec exec(exp, global_vars, local_vars) File "", line 2, in File "", line 2, in NameError: name 'x' is not defined
I'm using pycharm for debugging.