Answer: Your welcome!
Step-by-step explanation:
If read a list is chosen, you should then allow the user to enter in the file name they wish to read and print the items contained in that file to the screen.
# Program to Create/Read Shopping List
# Create an empty list to store items
shopping_list = []
# Ask the user if they wish to read a list or create a list
action = input("Do you wish to create a list or read a list? (create/read): ")
# Check the user's input
if action.lower() == "create":
item = input("Enter an item to add to your list (enter 'done' when finished): ")
# Loop until the user enters 'done'
while item.lower() != "done":
# Add the item to the shopping list
shopping_list.append(item)
# Ask the user for the next item
item = input("Enter an item to add to your list (enter 'done' when finished): ")
# Open a file to write the list to
file = open("shopping_list.txt","w")
# Loop through the list and write each item to the file
for item in shopping_list:
file.write(item + "\\")
# Close the file
file.close()
print("Your shopping list has been saved.")
print("Items in your list:")
# Print the list to the screen
for item in shopping_list:
print(item)
elif action.lower() == "read":
# Ask the user for the file name
filename = input("Enter the file name: ")
# Open the file
file = open(filename,"r")
# Read the contents of the file
contents = file.read()
# Close the file
file.close()
print("Items in your list:")
# Print the contents of the file to the screen
print(contents)
else:
print("Invalid input.")