Handle ValueError.
This commit is contained in:
@@ -102,23 +102,26 @@ def main():
|
||||
|
||||
y = "y"
|
||||
while y == "y":
|
||||
id = int(input("Please input the student ID number: "))
|
||||
try:
|
||||
id = int(input("Please input the student ID number: "))
|
||||
|
||||
if check_id(conn, id):
|
||||
day = get_lower_weekday()
|
||||
raw_time = select_final_time(conn, day, id)
|
||||
# if raw_time is None, student has no lessons today
|
||||
if raw_time != None:
|
||||
final_time = parse_time_string(raw_time)
|
||||
current_time = parse_time_string(time.strftime("%H:%M"))
|
||||
if current_time > final_time:
|
||||
if check_id(conn, id):
|
||||
day = get_lower_weekday()
|
||||
raw_time = select_final_time(conn, day, id)
|
||||
# if raw_time is None, student has no lessons today
|
||||
if raw_time != None:
|
||||
final_time = parse_time_string(raw_time)
|
||||
current_time = parse_time_string(time.strftime("%H:%M"))
|
||||
if current_time > final_time:
|
||||
print("Clear to leave.")
|
||||
else:
|
||||
print("Student does not have clearance.")
|
||||
elif raw_time == None:
|
||||
print("Clear to leave.")
|
||||
else:
|
||||
print("Student does not have clearance.")
|
||||
elif raw_time == None:
|
||||
print("Clear to leave.")
|
||||
else:
|
||||
print("Student does not exist in the database. Please try again.")
|
||||
else:
|
||||
print("Student does not exist in the database. Please try again.")
|
||||
except ValueError:
|
||||
print("That was not an integer, please try again.")
|
||||
|
||||
y = input("Press y key followed by enter to run again.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user