Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. def sum_of_values_and_indices(a):
  2. i=0
  3. new_total=0
  4. while i <len(a):
  5. total= a[i]+a.index(a[i])
  6. new_total +=total
  7. i+=1
  8. return new_total
  9.  
  10. print(sum_of_values_and_indices([1,2,3]))
  11. print(sum_of_values_and_indices([0,0,0,0]))
  12. print(sum_of_values_and_indices([]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement