Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

grList(l1) Write a function grList that takes a list l1 which includes the list of items for the grocery shopping. Assume you need to do

grList(l1) Write a function grList that takes a list l1 which includes the list of items for the grocery shopping. Assume you need to do grocery shopping for you and your friend. Your friend is allergic to peanut and carrot, so you should not buy them for him. You need to replace these two items with apple. Your function should check your shopping list and print a list for you and your friend. Since the function only accept one list as an input, you need to create your friends list and modify it inside the function. Your code should work with any length of the list. Print your friends list first. (Do not worry about the output formatting)

Sample Input 1 l1 = [water, chips, watermelon, peanut, napkins] Sample Output 1 My friend needs ['water', 'chips', 'watermelon', 'apple', 'napkins'] I need ['water', 'chips', 'watermelon', 'peanut', 'napkins']

Sample Input 2 l1 = [candy, lemonade, ginger, bread, water] Sample Output 2 My friend needs [candy, lemonade, ginger, bread, water] I need [candy, lemonade, ginger, bread, water]

Sample Input 3 l1 = [candy, peanut, carrot, bread, water] Sample Output 3 My friend needs [candy, apple, apple, bread, water] I need [candy, peanut, carrot, bread, water]

Python Answers Only!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

1. Describe the power of nonverbal communication

Answered: 1 week ago