Recently I'm considering using mainly python 3 although I have used python 2.7 so far.
But I encountered variable problem on python 3 as follows.
For example, the below code properly works in python 2.
#print a
a=1
I run the code named test.py many times on ipython console (python 2.7.16) in spyder 3.3.6.
After the first run, I remove # in the first line.
Then, ipython console outputs 1 which is a's value.
However, when I run the above code (the first line is replaced by #print(a)) similar to the above on ipython console (python 3.7.6) in spyder 4.0.1, ipython console outputs an error message,
NameError: name 'a' is not defined.
When I input a in the ipython console, the console outputs 1.
Can I do the same thing in my python 3 environment as I do in python 2?
Thank you in advance.