• + 1 comment

    hey, I'm new to pyhton. I just wanted to ask is this code fine? I've used greg_kaleka suggestion and modified your code a bit.

    n1,n2,n3 = input().strip().split(' ') n1,n2,n3 = [int(n1),int(n2),int(n3)] h1 = [int(h1_temp) for h1_temp in input().strip().split(' ')] h2 = [int(h2_temp) for h2_temp in input().strip().split(' ')] h3 = [int(h3_temp) for h3_temp in input().strip().split(' ')] ans=0

    s1=sum(h1)

    s2=sum(h2)

    s3=sum(h3)

    while(min(len(h1),len(h2), len(h3))!=0):

    if(s1==s2==s3):
        ans=s1
        break
    elif(s1==max(s1,s2,s3)):
        s1=s1-h1.pop(0)
    elif(s2==max(s1,s2,s3)):
        s2=s2-h2.pop(0)
    else:
        s3=s3-h3.pop(0)
    

    print (ans)