Invalid syntax on Ex18 also unable to run python 3.6 on linux

Hello I’m working on exercise 18 from LP3THW. I am unable to get it to run . I am running it on Ubuntu 16.04 LTS if you see the screen shot I tried to run python3.6 and it does nothing. When i run Python3 it gives a syntax error and when i run Python without a version number it gives me a syntax error again. I tried running this from my windows machine and it is not doing anything else also. Please see attached screenshot. Also I have indented the print commands but still getting the same error.


Look at the first line in the Traceback (the error output).
It tells you wich file and wich line the error is at
Next line shows you this line with a ^ somewhere.
This ”up arrow” points out the reason for the Error.
Last line in Traceback tells what kind of error occured.

def find_the_problem():
print(“Read in Traceback to get the reason”)
print(“Correct it and try again”)
if new error occurs:
print(“find next reason”)
print(“It should work now”)

“Not a real python code”

hmmmm maybe you can give me a clue…the code in the book looks exactly like what i have… i dunno

You need to run all your files with ”python3”

Which Python version do you have?
Check with: ”python -version”
You need version 3.6 for the book you are following

1 Like

Thanks for your reply. This is how I’m running my python files exactly that way ”python3” or to be exacty “python3.6” I’m a noob to Python and Linux but I have python 2.7 , 3, and 3.6 installed. Its weird because I’m running the same source code line by line on my windows machine and it does not give me any output it. So ok I get the wrong versions 2.7 and 3 give me syntax errors but why is version 3.6 not giving me any output? i run it and it returns me back to the command prompt on both windows and linux. I’m going to retype the code from scratch and try again… lol arrrg I thought it would be cool to program in Ubuntu argggg. Actually now I’m getting this error after playing around… i think there is something wrong with my python3.6 install…

It most likely isn’t something with your python installation. From looking at your first screen shot it appears that you have weird indents on your lines 18 - 21. Try dedenting those lines and see what happens. Should fix your code.

Also, something that brought me to this as the assumed error is the error you get on the last screen shot that you have provided. The error is: “IndentationError: unindent does not match any outer indention level.” So it would make me assume an issue with the indent on that line.

1 Like

Ok well I will call this a lesson in indention. If print lines 18-21 are indented it will not print at all. Thanks I got it to run!!! Line 15 was indented too much as well as 18-21. Screenshot from 2018-01-20 18-00-01

I think you solved this, but you also need to make sure that you’re running the right Python. In your first screenshot, you get no error with you type python3.6, then errors when you type python3 and python. I believe that’s because python3 is a copy of python3.4 or 3.5, and python is a copy of python2.7.