python - Hackerrank Weighted Average -


the question can found here

i'm trying calculate weighted average when try populate array loop doing nothing ?

size = raw_input() arr = raw_input() w = raw_input() deger = [1,2,2,2,2]   size = [int(i) in size.split()] size = size[0] arr = [int(i) in arr.split()] w = [float(i) in w.split()]     def wm (x,y,s):   in range(0,s-1):     deger[i] = int(input(x[i]*y[i]))    return sum(deger)     print(wm(arr,w,size))   

just modifications based on code proper indentation:

size = raw_input() arr = raw_input() w = raw_input() #deger = [1,2,2,2,2] # not necessary initialize 'deger' here   size = [int(i) in size.split()] size = size[0] arr = [int(i) in arr.split()] w = [float(i) in w.split()]    def wm (x,y,s):     deger = [] # initialize empty 'deger' here     in range(0,s): # 's-1' not include last item of x , y         deger.append(x[i]*y[i])     return sum(deger) / sum(y)   print('%.1f'%wm(arr,w,size)) # 1 decimal place required 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -