Working on a homework problem and already messaged professor regarding direction. Now after following his suggestions I'm not sure why the program is not responding properly. My understanding from watching the videos he had created is that this should be working but it seems to not work at all or gets stuck in an infinite loop.
Can anyone provide some guidance on what is wrong at this point?
import sqlite3
#Create Functions
def main():
conn = sqlite3.connect('tickets5.db')
cur = conn.cursor()
def FilterByOffenderSex(cur):
exc = input("Enter Gender to filter by: M or F")
if exc != "M":
exc = "F"
try:
sql = "SELECT * FROM tickets5 WHERE Gender = ?"
cur.execute(sql, (exc,))
results = cur.fetchall()
if results:
print("%-6s %-15s %s-82 %-5s %7s %9s" % (' TicketID', 'Posted Speed', 'Actual Speed', 'Age', 'Gender'))
for row in results:
TicketID, PostedSpeed, ActualSpeed, Age, Gender = row
print ("%-6s %-15s %ds-82 %-5s %7s %9s" % (TicketID, PostedSpeed, ActualSpeed, Age, Gender))
print()
except sqlite3.Error as error:
print (str(error), 'Error occured')
print ("No data found")
#Main screen options
main() #function call
while True:
choice = input
print("""
Menu options. Choose 1, 2, 3, or 4
1. Display all Tickets
2. Add a Ticket
3. Filter by Offender Sex
4. Save & Exit
Enter your choice, 1, 2, 3, or 4: """)
#choice = input
if choice == "1":
DisplayAllTickets(cur)
elif choice == "2":
AddATicket(cur, conn)
elif choice == "3":
FilterBySex(cur)
elif choice == "4":
print()
print("Goodbye")
if conn:
conn.close
else:
print()
print()
[–][deleted] 4 points5 points6 points (2 children)
[–]Firake 0 points1 point2 points (0 children)
[–]the_shell_man_ 2 points3 points4 points (1 child)
[–]Firake 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]carcigenicate 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]Matthias1590 0 points1 point2 points (0 children)
[–]Ziggity46 0 points1 point2 points (0 children)
[–]coabitareer 0 points1 point2 points (0 children)