[Tutor] Still Can't Find Timed While Loops

bob gailer bgailer at alum.rpi.edu
Fri Dec 7 16:41:30 CET 2007


earlylight publishing wrote:
> Hello all,
>  
> I now have my bit of code in while loop form and it works!  It's great 
> but not exactly what I wanted to do.  I've been googling my heart out 
> and I find lots of info on while loops and lots of info on timers that 
> will execute an action AFTER a given interval but nothing on a timer 
> that will execute an action DURING a given interval.  What I'd really 
> like to do at this point in my game is have the player execute the 
> loop for 30 seconds then have it print the final score and break.  
> Does anyone out there have any code that'll do that?
import time
start = time.time()
raw_input("Wait a few seconds, then press enter to continue.")
print time.time() - start

Does that give you a hint?

You don't need a timer, unless you want to interrupt the user if he is 
not entering anything.



More information about the Tutor mailing list