I am building a code to accept inputs and separate those inputs based on category type. When I input my expense, the expense always appends to the "bills" list. Further, when asked if want to add another expense, doesn't matter what I input, the program ends rather than continues to move through the while loop.
# Create a program that sorts expenses by category after accepting user input.
# Define the lists that the expenses will be separated into.
bills = []
fun = []
take_out = []
def items_list():
"""A function to input expenses and sort them by category."""
print("Please add your expenses here.")
name = input("Name: ")
cost = input("Cost: ")
category = input("Category: ")
expense = f"{name}, {cost}, {category}"
# Add a flag to indicate that the program is ready to accept expenses.
add_items = True
# Add a while to accept expenses
while add_items:
# Separate the expense based on the category they fall under.
if category == str("Bill") or str("bill"):
bills.append(expense)
elif category == str("Fun") or str("fun"):
fun.append(expense)
elif category == str("Take Out") or str("take out"):
take_out.append(expense)
# Ask the user if they would like to add another item.
repeat = input("Would you like to add another expense? (Yes/No): " )
if repeat == "No" or "no":
add_items = False
items_list()
print(bills)
print(fun)
print(take_out)