Guest User

Untitled

a guest
Feb 21st, 2020
86
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #This sum_of_values_and_indices function accepts a lsit of numbers and returns the sum of the elements along with their index value
  2.  
  3. def sum_of_values_and_indices(value):
  4.     total = 0
  5.     addition = []
  6.     value2 = value.copy()
  7.     total_sum = []
  8.     for number in value:
  9.         #print(value.index(number))
  10.         addition.append(value.index(number))
  11.         #print (addition)
  12.         total_sum = [x + y for x, y in zip(value2, addition)]
  13.         #print (total_sum)
  14.    
  15.     for i in total_sum:
  16.         total += i
  17.     return total
  18.  
  19. print((sum_of_values_and_indices([5, 9, 3, 7])))
  20. print((sum_of_values_and_indices([])))
RAW Paste Data