Question: Let's write a function to collect a grocery list from a user. This function should return a list of strings: def collect _ grocery _

Let's write a function to collect a grocery list from a user. This function should return a list of strings:
def collect_grocery_list()-> List[str]:
pass
When the function is called, the user is repeatedly asked for a grocery list item until they type "STOP":
>>> print(collect_grocery_list())
Please enter a grocery item (or STOP): milk
Please enter a grocery item (or STOP): tea
Please enter a grocery item (or STOP): bread
Please enter a grocery item (or STOP): peanut butter
Please enter a grocery item (or STOP): STOP
['milk', 'tea', 'bread', 'peanut butter']Let's write a function to collect a grocery list from a user. This function should return a list of strings:
def collect_grocery_list()-> List[str]:
pass
When the function is called, the user is repeatedly asked for a grocery list item until they type "STOP":
>>> print(collect_grocery_list())
Please enter a grocery item (or STOP): milk
Please enter a grocery item (or STOP): tea
Please enter a grocery item (or STOP): bread
Please enter a grocery item (or STOP): peanut butter
Please enter a grocery item (or STOP): STOP
['milk', 'tea', 'bread', 'peanut butter']

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!