[Tutor] Syntac Error

Alan Gauld alan.gauld at yahoo.co.uk
Wed Apr 24 02:31:12 EDT 2019


On 24/04/2019 00:31, Bob Griffin wrote:
> Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit (Intel)] on win32
> Type "copyright", "credits" or "license()" for more information.
>>>> print("Game Over")
> Game Over
>>>>

> When I run the program and get a syntac error invalid syntac that highlights the first 1 in 3.1.1 above.

OK, That suggests that there is a problem in the way you
are trying to run the program. It seems like you are typing
the Python 3.1.1 message as part of your code. That's not
what you are supposed to do.

When you start the Python interactive interpreter by
typing py at the Windows command prompt (or using
the Windows+"R" dialog) you should get a console window
which already contains everything down to the first >>>
You do not type that in.

The only bit you type in is the

print("game over")

> When I save the program and try to run it from the app on 
> my screen it just blinks and goes back to the app on my desktop.

I'm not sure which app you are referring to but I'll take
a guess at what is happening. The interpreter is starting up,
running until the error is displayed then closing again.
All so fast that you cannot see it.

Try adding a line like

input("Hit Enter to quit")

at the end of your code.

So the whole program should just contain the two lines:

print("Game over")
input("Hit Enter to quit")

Try running that.
Hopefully you get the output

Game over
Hit Enter to quit

HTH
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list