Question: In [ ]: In [ ]: In [ ]: In [ ]: Q2 - Method II (1.25 points) .split() is a built-in string method

In [ ]: In [ ]: In [ ]: In [ ]:

In [ ]: In [ ]: In [ ]: In [ ]: Q2 - Method II (1.25 points) .split() is a built-in string method that "returns a list of the words in the string". .count() is a built-in list method that "returns the number of times a specified value occurs in a tuple." You may wish to examine the contextual help for both methods to do this problem. In the cell below, the variable students_fruits has been provided for you. Using only students_fruits and the methods split() and count(), generate the three variables specified at left in the bulleted list below, satisfying the following criteria: apple_count the number of times 'apple' shows up in students_fruits lychee_count | the number of times 'lychee' shows up in students_fruits pineapple_count | the number of times 'pineapple' shows up in students_fruits Do not hard-code. Use your code to process the list so that we could change the list and you'd still generate the correct answer automatically. That is DON'T write something like: apple_count = 5 Note you will have to execute the cell with the variable provided below before being able to reference it in your answer. 1 hese variables provided for you 2 ou will not be able to edit this cell 3 4 dents fruits = 'apple apple apple banana pear dragonfruit starfruit apple pear pineapple apple grapefruit lime lych 5 6 nt (students fruits) 1 # ignore this cell; it's being used in grading 2 # be sure to put your answer in the cell below this cell 3 1 #your code here 2 raise Not ImplementedError 1 assert apple_count is not None

Step by Step Solution

3.36 Rating (149 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To solve this problem we can follow these steps Split the string studentsfruits in... View full answer

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 Programming Questions!