- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python â€“ Find Product of Index Value and find the Summation
When it is required to find the product of the index value and the summation, the ‘enumerate’ attribute is used.
Below is a demonstration of the same
my_list = [71, 23, 53, 94, 85, 26, 0, 8] print("The list is :") print(my_list) my_result = 0 for index, element in enumerate(my_list): my_result += (index + 1) * element print("The resultant sum is :") print(my_result)
The list is : [71, 23, 53, 94, 85, 26, 0, 8] The resultant sum is : 1297
A list of integers is defined and is displayed on the console.
An integer value is assigned to 0.
The enumerate value is used to iterate through the list.
The index is multipled with the respective element and this is added to the integer value.
This is the output that is displayed on the console.
Kickstart Your Career
Get certified by completing the courseGet Started