I'm an extremely new to coding and I'm writing simple short scripts to learn and practice. I'm following a textbook and I reached the chapter working with inputs. Even after following the code character for character, it wouldn't compile. Eventually, I figured out that I was using python3 grammar while the computer seemed to be expecting python2.
How can I get my computer to recognize the python3 grammar?
The code is written in atom so at first I fished around for a package that might somehow take care of it. Then a friend came over and we spent about two hours ramming our heads into it. Finally, he set up this thing called IDLE which produces a python3.6.7 shell which does run the code, so I know its possible. I've also looked at other forums and one solution that seemed to fit the bill was setting up an alias in bash. However, when I tried to access the bash file from my home directory, it denied me access. Also, I slightly scared of doing that because I saw a post from another novice saying he messed with his bash and now he cant log in to his device. In short, there's probably a simple solution to this but I'm too new to have heard of it.
Btw, I'm running Ubuntu 18.04 as my OS
Here's the code:
message = input('a')
print(message)
Thats the whole script. Two lines. It should simply print 'a' to the console, accept whatever I type, and then print that back out the console. In stead, it produces this error:
aWhatever
Traceback (most recent call last):
File "/home/username/Desktop/Coding Projects/Python-Projects/Python-Projects/inputs_and_while_loops.py" line 1, in <module>
message = input('a')
File "<string>", line 1, in <module>
NameError: name 'Whatever' is not defined
=================================================
(The program excited with code: 1)
Press any key to continue...
Again, the code is written in python3 grammar while this seems to be expecting python2 grammar (which when I change it to, it works)
I know you experienced devs out there are probably laughing at how simple a problem this is, but please help a young fledgling coder if you've got the time. Also keep in mind that I know basically nothing about programming and working ubuntu, so if you've got the answer, please go into as much detail as possible and explain literally everything. Proper use of the word literally. I am doing this to learn after all.
Thanks for taking a moment to read this!
Edit: To be clear, I am writing this code in the Atom IDE. User paul41 provided a method that worked (thanks paul) by cd-ing into the directory the script was contained in and using the python3 command on the file. While this does get it to compile, its slightly unwieldy and I was looking for a way to get it to compile from Atom. My current package that I am using to run code is python-run-terminalnx. Heres the link to the page: https://atom.io/packages/python-run-terminalnx Since this package opens up a terminal window to run the code, I thought that there was some setting somewhere in my PATH (which I still don't quite understand how to use) that I could change with a command to get it to use python3 grammar instead of python2 grammar when compling python scripts as a default. Sorry, I should have been clearer