Intuitivize exit sequence.

This commit is contained in:
Abdulkadir Furkan Şanlı 2019-01-11 12:53:06 +01:00
parent ce7286545b
commit 42e6042405

View File

@ -17,6 +17,13 @@
import sqlite3 import sqlite3
import time 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): def connect_database(file):
@ -145,7 +152,12 @@ def main():
else: else:
print("\nStudent still has lessons, clearance not granted.") 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 break