<jupyter_start><jupyter_text>Now You Code 2: Shopping ListWrite a program to input a list of grocery items for your shopping list and then writes them to a file a line at a time.  The program should keep asking you to enter grocery items until you type `'done'`.After you complete the list, the program should then load the file and read the list back to you by printing each item out.Sample Run:```Let's make a shopping list. Type 'done' when you're finished:Enter Item: milkEnter Item: cheeseEnter Item: eggsEnter Item: beerEnter Item: applesEnter Item: doneYour shopping list:milkcheeseeggsbeerapples```  Step 1: Problem AnalysisInputs:Outputs:Algorithm (Steps in Program):<jupyter_code>filename = "NYC2-shopping-list.txt"
w=open(filename, "w")
while True:
    item=input("Enter item: " )
    w.write(item)
    if item=='done':
        break
filename = open("NYC2-shopping-list.txt")

content = filename.read()

filename.close()

print("your list is: ", content)<jupyter_output>Enter item: bacon
Enter item: ee
Enter item: done
your list is:  baconeeedone<jupyter_text>Step 3: RefactoringRefactor the part of your program which reads the shopping list from the file into a separate user-defined function called `readShoppingList` re-write your program to use this function. ReadShoppingList functionInputs:Outputs:Algorithm (Steps in Program):<jupyter_code>## Step 4: Write program again with refactored code.
def readShoppingList():
    shoppingList = [open(filename, "w")]
    # todo read shopping list here
    w=open(filename, "w")
    while True:
        item=input("Enter item: " )
        w.write(item)
        if item=='done':
            break
    filename = open("NYC2-shopping-list.txt")

    content = filename.read()

    filename.close()

    print("your list is: ", content)
    return shoppingList


# TODO Main code here<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09251336898395722, 'fraction_numerical': 0.0037433155080213902, 'mean_word_length': 4.376436781609195, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '554912', 'license': 'MIT', 'n_tokens_mistral': 559, 'n_tokens_neox': 548, 'n_words': 208, 'path': 'content/lessons/07/Now-You-Code/NYC2-Shopping-List.ipynb', 'repo_name': 'MahopacHS/spring-2020-luongom0112', 'size': '1870'}