Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def sum_of_values_and_indices(a):
- i=0
- new_total=0
- while i <len(a):
- total= a[i]+a.index(a[i])
- new_total +=total
- i+=1
- return new_total
- print(sum_of_values_and_indices([1,2,3]))
- print(sum_of_values_and_indices([0,0,0,0]))
- print(sum_of_values_and_indices([]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement