
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Compute Power by Index Element in List using Python
When it is required to compute the power by index element in a list, the simple iteration along with the ‘**’ operator is used.
Example
Below is a demonstration of the same
my_list = [62, 18, 12, 63, 44, 75] print("The list is :") print(my_list) my_result = [] for my_index, elem in enumerate(my_list): my_result.append(elem ** my_index) print("The result is :") print(my_result)
Output
The list is : [62, 18, 12, 63, 44, 75] The result is : [1, 18, 144, 250047, 3748096, 2373046875]
Explanation
A list is defined and is displayed on the console.
An empty list is defined.
The list is iterated over and the element raised to the power of the index is appended to the empty list.
This is displayed as output on the console.
Advertisements