Well i just bought "python for the absolute begginer" and title says it all.

The task at the end of the chapter wants me to print "Game over" and then write something like '\n\nPress the enter key to exit.' which i causes the program with double click however this is at the end of the chapter and it's not very well explained and when i click run i get "invalid syntax" error and the top the number "1" of the version name is underlined in red.

Anyway here is my code please help me :

Python 3.1 (r31:73574, Jun 26 2009, 20:21:35) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> print ("Game Over")
Game Over
>>> ("\n\nPress the enter key to exit.")


'\n\nPress the enter key to exit.'

I open run in script window i think which is the extra one and i click run however i dont know why in the tutorial the guy had opened python shell.

I think the task at the end of the chapter is for you to discover how to use input() to accept input from the keyboard, and then print "Game Over" and exit.

Think of Python as a little robot that does exactly and only what you tell it to do. If you want it to print something, you give it (part of) a script that says print("something") If you want it to accept input from the keyboard, you give it (part of) a script that says, for instance, user_input = input("Press the <Enter> key to exit.") and it will print that prompt and wait for the keyboard to get some input. You can check what the user entered by looking at the value of user_input but in this simple case, there's no need.

P.S. Please use the (CODE) button so we can see line numbers, code coloring and correct indentation.

commented: thanks :)) +0

You have just paste code into IDLE(python shell),that dos not work.
Do this file->new window now copy code under and paste code into the new window you got.

print ("Game Over")
input("Press the enter key to exit.")

Save the file with .py extension(somthing.py)
Now you can press F5 or Run Module from the menu.

IDLE(python shell) you can just type in 1 line and you have to hit enter after every line(if test more than line) and you se output immediately and also without print.

>>> print ("Game Over")
Game Over

>>> ("Game Over")
'Game Over'
>>> 
          
>>> for i in range(3):
...     i
...     
0
1
2
   
>>> a = 'hello'
>>> for word in a:
...     word
...     
'h'
'e'
'l'
'l'
'o'
>>>

Get a god editor make it eaiser to run code like pyscripter.
http://code.google.com/p/pyscripter/

commented: Thankss :) +0

Ok thank you everyone for your answers and fast support it worked as a charm.

Thanks again

--------------------------------------------------------------------
By the way snippsat is this program compatible with python 3.1 ?

By the way snippsat is this program compatible with python 3.1 ?

Yes.

OK so it worked yesterday somehow but now when i try into new python thing i type

print ("Game Over")
input("Press the f key to exit lol.")

In the new window in python and i open the module with f5 and i get some thing like syntax erorr or either sometimes it works and when i close both of them i cant open the file with double click. I looked at the other file that worked perfectly and i copy the exact same thing however it doesnt work :( Any suggestions? Because i dont feel readdy to countinue to chapter two without doing it properly.
I appreciate all the help xD

Also when i open the working file in python shell i get this

Python 3.1 (r31:73574, Jun 26 2009, 20:21:35) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>> 
Game Over
Press the f key to exit lol.

http://img716.imageshack.us/i/wellw.jpg/

It's really confusing me xD

And if someone is willing to help me via skype i will appriciate it xD

You are trying to execute the interactive interpreter buffer content instead of the py file you saved yesterday in IDLE editor.

Open your code from File->Open. Then push F5.

oh tyvm forr the answer and sorry for asking sucha stupid questions xD

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.