[Tutor] Waiting for input.
Danny Yoo
dyoo@hkn.eecs.berkeley.edu
Tue, 30 Oct 2001 15:06:08 -0800 (PST)
rOn Tue, 30 Oct 2001 kromag@nsacom.net wrote:
> (I just found the range() function, so this will change soon! :-) It kinda
> works like I want it to at this point....)
>
> I would like to have the following function pause between loops:
By "pause", do you want your program to wait until you've pressed a key,
or do you mean something like "wait for a few seconds"?
If it's the "Press any key to continue" kind of pause, you might want to
try raw_input():
###
>>> raw_input("Press Enter to continue: ")
Press Enter to continue:
''
###
The idea is that we use raw_input() just to force the program to wait for
the user to interact with our program.
If it's the "wait for a few seconds" kind of pause, you may want to look
at time.sleep():
###
>>> print time.sleep.__doc__
sleep(seconds)
Delay execution for a given number of seconds. The argument may be
a floating point number for subsecond precision.
###
Hope this helps!