Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def sum_of_values_and_indices(list):
- total_sum = 0
- '''iterating over the list and summing all
- values in the list along with their index
- positions, we have:'''
- for values in list:
- total_sum += values + list.index(values)
- '''total_sum = total_sum + values +
- list.index(values)'''
- return total_sum
- print(sum_of_values_and_indices([1, 2, 3]))
- print(sum_of_values_and_indices([8, 7]))
Add Comment
Please, Sign In to add comment