- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
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 Program to find the cube of each list element
When it is required to find the cube of each list element, a simple iteration and the ‘append’ method are used.
Example
Below is a demonstration of the same
my_list = [45, 31, 22, 48, 59, 99, 0] print("The list is :") print(my_list) my_result = [] for i in my_list: my_result.append(i*i*i) print("The resultant list is :") print(my_result)
Output
The list is : [45, 31, 22, 48, 59, 99, 0] The resultant list is : [91125, 29791, 10648, 110592, 205379, 970299, 0]
Explanation
A list is defined and is displayed on the console.
An empty list is defined.
The original list is iterated over.
Every element is multiplied with itself thrice.
This result is appended to the empty list.
This is the result that is displayed on the console.
- Related Articles
- Python program to get the indices of each element of one list in another list
- Program to find sum of concatenated pairs of all each element in a list in Python?
- Python program to create a list of tuples from the given list having the number and its cube in each tuple
- C# Program to find the cube of elements in a list
- Program to find replicated list by replicating each element n times
- Python – Find the frequency of numbers greater than each element in a list
- Python Program to assign each list element value equal to its magnitude order
- Python Program to Find the Largest Element in a Doubly Linked List
- Program to find sum of the minimums of each sublist from a list in Python
- Python Program to Find Element Occurring Odd Number of Times in a List
- Program to perform given operation with each element of a list and given value in Python
- Adding K to each element in a Python list of integers
- Python program to Sort a List of Tuples in Increasing Order by the Last Element in Each Tuple
- Python Program to calculate the area of Cube
- Python Program to calculate the volume of Cube

Advertisements