Question: Fix this code def solution(A): #initialize the bucket myBuckets =[] #store number of fruits count =0; #loop for fruits in A for i in A
Fix this code
def solution(A): #initialize the bucket myBuckets =[] #store number of fruits count =0; #loop for fruits in A for i in A : #if fruit not in the buckets if not myBuckets.__contains__(i): #if bucket length less than two if len(myBuckets)
print(" ") A = [1,2,1,2,1,2,1] print(A) maxFruits=solution(A) print("She can collect max:",maxFruits,"fruits")
Problem:
![Fix this code def solution(A): #initialize the bucket myBuckets =[] #store number](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f59c7c23964_41166f59c7b993fe.jpg)
Test Output Example test: [1, 2, 1, 2, 1, 2, 11 Output: She can collect max: 1 fruits She can collect max: 1 fruits WRONG ANSWER (got 1 expected 7) Producing output might cause your solution to fail performance tests. You should remove code that produces output before you submit your solution. Test Output Example test: [1, 2, 1, 2, 1, 2, 11 Output: She can collect max: 1 fruits She can collect max: 1 fruits WRONG ANSWER (got 1 expected 7) Producing output might cause your solution to fail performance tests. You should remove code that produces output before you submit your solution
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
