def test_scope():
i = 0
while(i<3):
j = i
i += 1
print (j)
I saw other's code like this. j only exists in the while scope, but it seems valid in Python. In PyCharm, it gives a warning that 'j' can be undefined, but it doesn't throw an error. I likes to define the 'j' with some initial value before the while loop.
Is this good practice in Python using an out-of-scope variable?