Question: only python Net Gain Function Name: netGain() Parameters: buy and sell history (str) Returns: net gain (int) Description: You've bought and sold a particular stock

only python Net Gain Function Name: netGain() Parameters: buy and sell historyonly python

Net Gain Function Name: netGain() Parameters: buy and sell history (str) Returns: net gain (int) Description: You've bought and sold a particular stock several times, and want to know your net gain. You have a string of bs and ss that represent your history of buying and selling. A b represents buying a stock at the price of the inde at which it occurs in the string. Simi- larly, an s represents selling a stock at the price of the index at which it occurs in the string. Find and return the total gain or loss of stocks by subtracting the sum of the indices of b s from the sum of indices of s s. >>> netGain("bbbsss") 9 >>> netGain("bsbsbs") 3

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!