Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Timed Exit
#1
Hello, I am making a Python game where there is a sequence of letters, and you have to guess it right within a certain amount of time. However, once the player pushes enter, the code is reviewed. Unless, of course, the time runs out, in which case it just passes. Here is my current code:

now = time.time()
        limit = now + 15
        while time.time() < limit:
            r2 = raw_input("Commands:")
            pass
        word2 = 'sddddwwdddx'
        for i in range(min(len(r2), len(word2))):
            if r2[i] != word2[i]:
                errors += 1
        if errorlevel >= errors or errors == 0:
            print"Your plane sucsessfully went through the course!"
        else:
            pass
However, the person could not press enter until the time is up, but since they don't know when time is up, they have to wait much longer. How could I make it so when you press enter, it exits out of the while loop, but also immediately ends the person's choice if the time is up?

Thank You.
Reply


Messages In This Thread
Timed Exit - by Tbot - Apr-08-2018, 01:38 PM
RE: Timed Exit - by DeaD_EyE - Apr-08-2018, 02:38 PM
RE: Timed Exit - by Tbot - Apr-08-2018, 03:06 PM
RE: Timed Exit - by DeaD_EyE - Apr-09-2018, 06:18 AM
RE: Timed Exit - by Tbot - Apr-09-2018, 12:22 PM
RE: Timed Exit - by nilamo - Apr-09-2018, 07:08 PM
RE: Timed Exit - by Tbot - Apr-10-2018, 12:09 AM
RE: Timed Exit - by nilamo - Apr-10-2018, 01:06 AM
RE: Timed Exit - by DeaD_EyE - Apr-10-2018, 08:16 AM
RE: Timed Exit - by Tbot - Apr-10-2018, 12:46 PM
RE: Timed Exit - by nilamo - Apr-10-2018, 03:46 PM
RE: Timed Exit - by Windspar - Apr-10-2018, 10:45 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020