Question: Python Fix this code def solution(A): #initialize the bucket myBuckets =[] #store number of fruits count =0; #loop for fruits in A for i in

Python

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")

Python Fix this code def solution(A): #initialize the bucket myBuckets =[] #store

Problem:

number of fruits count =0; #loop for fruits in A for i

def solution (A): #initialize the bucket myBuckets [l #store number of fruits count0; #loop for fruits in A for i in A: #if fruit not in the buckets if not myBuckets.__contains__(i): #lf bucket tenath Less than two if lep (myBuckreadi: #add fruit in the bucket myBuckets append(i) #else break the loop else: break count+-1 return count maxFruits-solution(A) print(A) print("She can collect max:", maxFruits,"fruits") print(" ") print(A) maxFruits-solution(A) print("She cancollect max:",maxFruits,"fruits") def solution (A): #initialize the bucket myBuckets [l #store number of fruits count0; #loop for fruits in A for i in A: #if fruit not in the buckets if not myBuckets.__contains__(i): #lf bucket tenath Less than two if lep (myBuckreadi: #add fruit in the bucket myBuckets append(i) #else break the loop else: break count+-1 return count maxFruits-solution(A) print(A) print("She can collect max:", maxFruits,"fruits") print(" ") print(A) maxFruits-solution(A) print("She cancollect max:",maxFruits,"fruits")

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!