import sqlite3 conn = sqlite3.connect("bj.db") cursor = conn.cursor() print("Welcome to B&J's!!!") print("What's your favorite flavor of ice cream?") cursor.execute("select distinct flavorName from recipe") results = cursor.fetchall() for i, result in enumerate(results, start=1): print(f"{i}) {result[0]}") their_choice = int(input("> ")) if their_choice > len(results): print("You dummy! You entered too high a number!") their_fave_flavor = results[their_choice-1][0] cursor.execute("select name from recipe where flavorName=?", (their_fave_flavor,)) results = cursor.fetchall() print(f"Which {their_fave_flavor}-based ice cream would you like to order? ") for i, result in enumerate(results, start=1): print(f"{i}) {result[0]}") their_choice = int(input("> ")) if their_choice > len(results): print("You dummy! You entered too high a number!") their_recipe = results[0][0] print(f"How many cartons of {their_recipe} would you like to order? ") num_cartons = int(input("> ")) cursor.execute("update recipe set cartonsOrdered=cartonsOrdered+? where name=?", (num_cartons, their_recipe, )) conn.commit() cursor.execute("select cartonsOrdered from recipe where name=?", (their_recipe,)) total_ordered = cursor.fetchall()[0][0] print(f"Yay! There are now {total_ordered} cartons of {their_recipe} on order.")