Changing Python version via script


Just curious, Is there a way to the change the python version from the script editor?


Hi @aquaphoenix17,

It would be nice to be able to do that.

If you would like to use the Codecademy script editor to run a program in a Python 3 interpreter, it probably will not work. However, you can execute a Python 3 program from a Python 2 program on your own system if you have both Python versions installed.

  • Create two files as follows, naming them based on the comments.
  • Run the first file in Python 2.x

import os
print("Hello World from Python 2.7!")
print("Let's execute a Python 3.6 program!")

The above file will execute the file below ...

print("Hello World from Python 3.6!")

Interactive session in Terminal ...

$ python2.7
Hello World from Python 2.7!
Let's execute a Python 3.6 program!
Hello World from Python 3.6!

However, that's probably not what you hoped to do.