Question: Given the following parallel lists, write a few python statements to print the price of a Twix bar. Assume that you don't know where 'Twix'


Given the following parallel lists, write a few python statements to print the price of a Twix bar. Assume that you don't know where 'Twix' is in the list and you have to find it. candyList priceList = ['Kit Kat', 'Mounds','Twix','Snickers','Almond Joy'] [1.10,1.15,0.95,1.00,1.20] The following function counts the number of occurrences of a particular character in a string. def countChar(instring, char): count = 0 for i in range (len (instring)): if char == inString[i]: count = count + 1 return count Create a new function, charpos, by modifying the countchar function so that it finds the locations of all instances of the character in the string, and returns the list of those indexes. For example, the call to your function: charpos ('computer science','e') would return the list: [6, 11, 14] because the letter 'e' appears in positions, 12 and 15 in the string 'computer science
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
