0

I have installed both python 2.7 and python 3.6 on my computer, and I have a file called first.py which contains two lines of code:

print("hello")
print "hi"

and in my command line , I just simply type first, and it will print out

hello
hi

Why is that? I thought print() is a feature of python 3 and would not work for the second line of my code. Also, is it fine for me to have both python versions installed?

tyteen4a03
  • 1,812
  • 24
  • 45
  • I'm going to guess that 3 isn't installed properly, so this is being evaluated using the 2 interpreter. That's valid code in 2. – Carcigenicate Mar 09 '17 at 23:56
  • @Carcigenicate: Not necessarily. `py.exe` may simply be defaulting to interpreting using 2.7. On 3.6 that shouldn't be the case (in 3.6, failing to specify a version for `py.exe` for an un-shebanged file _should_ go to Py3, in 3.5 and earlier it defaulted to Py2). You'd have to check the file type associations for `.py` files (you want it to be `py.exe`). – ShadowRanger Mar 10 '17 at 02:28

0 Answers0