Intuitivize exit sequence.
This commit is contained in:
parent
ce7286545b
commit
42e6042405
@ -17,6 +17,13 @@
|
||||
|
||||
import sqlite3
|
||||
import time
|
||||
from os import name
|
||||
|
||||
# Import getch from msvcrt if running on Windows.
|
||||
if name == "nt":
|
||||
from msvcrt import getch
|
||||
else:
|
||||
from getch import getch
|
||||
|
||||
|
||||
def connect_database(file):
|
||||
@ -145,7 +152,12 @@ def main():
|
||||
else:
|
||||
print("\nStudent still has lessons, clearance not granted.")
|
||||
|
||||
if input("Enter y to run again.") not in ["y", "Y"]:
|
||||
print("\nPress X key to exit, other key to run again.")
|
||||
key = getch()
|
||||
# msvcrt.getch returns type bytes, decode into str.
|
||||
if isinstance(key, bytes):
|
||||
key = key.decode()
|
||||
if key.upper() == "X":
|
||||
break
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user