Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In python plz 2. Write a function takePoll that takes a list of strings as a parameter and polls the user to build a dictionary
In python plz
2. Write a function takePoll that takes a list of strings as a parameter and polls the user to build a dictionary out of the options in the list. The function builds the dictionary by repeatedly asking the user to enter one of the strings in the list. The function then records the choice in the dictionary, creating entries as needed. You can assume that the items in the list are in all lowercase. The user can type entries in a mix of lower- and uppercase. If an item not in options is entered, it is recorded as a choice for 'other.Only the values entered by the user are recorded in the dictionary the function builds, so that if the user fails to pick one or more of the items in the list, then the dictionary will not contain an entry for that item. The function stops and returns the dictionary when the user presses enter without typing any text. The following shows several sample runs of the function. Your function must work as described, and the sample runs are only designed to illustrate some of the cases you may encounter 2/4 2/20/2018 Assignment -CSC 241-801 python 3.62 Shell Eile Edit Shell Debug Options Window Help >>> catdict takePoll'djengo', prudencegtrude'] The options are: ['djengo', 'prudence', "gertrude'] Enter your choice: DJENGO The options are: ['djengo'prudence''gertrude' Enter your choice: djengo The options are: 'djengo', prudencegertrude'1 Enter your choice: Prudence The options are: ['djengoprudence' gertrude 1 Enter your choice: Gertrude The options are: ['djengo'prudence'gertrude' Enter your choice: DJeNgo The options are: ['djengo', prudencegertrude' Enter your choice: tardar The options are: ' djengoprudence''gertrude 1 Enter your choice: Thanks for choosing catdict 'djengo': 3, 'prudence' 1, 'gertrude': 1,other' 1) >>>dessert takePoll(' pie', chocolate', ice cream) The options are: 'pie'chocolate' 1ce cream Enter your choice: PIE The options are: ['pie chocolate, ice cream Enter your c The options are: ['pie'chocolateice crea Enter your choice: ice The options are: 'pie', chocolate''ice crea1 Enter your choice: Thanks for choosing! oice: pie 'pie 2, other: 1) >>> empty = takepoll (['knife', 'fork', 'spoon']) The options are: [ ' knife' , ' fork' , 'spoon. ] Enter your choice: Thanks for choosing empty Ln: 83 Col:4Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started