- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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.
- Program to find a list of product of all elements except the current index in Python
- Python Pandas - Compute indexer and find the previous index value if no exact match
- Python Pandas - Compute indexer and find the next index value if no exact match
- Python Pandas - Compute indexer and find the nearest index value if no exact match
- Program to find largest kth index value of one list in Python
- How to find the index of the minimum and maximum value of a vector in R?
- Vector inner product with Einstein summation convention in Python
- Vector outer product with Einstein summation convention in Python
- How to find the last index value of a string in Golang?
- Python Program to Find the Product of two Numbers Using Recursion
- Program to find sign of the product of an array using Python
- Python - Find starting index of all Nested Lists
- Python program to find Cartesian product of two lists
- Find the column index of least value for each row of an R matrix