def removeCoin(): coinlist = ["a", "b", "c", "d"] while True: print("\nThe list of coins you're currently tracking is: \n" + "\n".join(coinlist) + "\n") yes_or_no = input("Do you want to remove a coin from the list? (Y/N):").upper() if yes_or_no == "Y": try: coinlist.remove(input("Which coin do you want to remove?").upper()) print("\nThe list of coins you're currently tracking is: \n" + "\n".join(coinlist) + "\n") except ValueError: print("There is no such coin in the list") if yes_or_no == "N": return coinlist else: "You didn't input a valid coin" removeCoin()