Question: Using PYTHON: You invited your friends to your house for a barbeque. Being the good friends that they are, they offered to bring food. Using

Using PYTHON: You invited your friends to your house for a barbeque. Being the good friends that they are, they offered to bring food. Using the starter code below, build a dictionary to show who will bring what food to the gathering. Loop through the list of friends. For each friend, use the random.choice() Links to an external site. method to select a food at random from the food list. Once a food is selected, it should be removed from the food list. Add each friend-food pair as a key-value pair to the dictionary. (The video in the previous question shows how to make the random assignment).
import random
friends =["Sam", "Joe", "Pat", "Tom"]
food =["chips", "rolls", "salad", "dessert"]
who_brings_what ={}
# Fill in missing code
print(who_brings_what)
This exercise will be manually graded, 1 point apiece for:
loop through list of friends
food randomly selected
food choice removed from list
friend-food pair added to dictionary
comments

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!