How to divide each element in a list in Python

Dividing each element in a list by a number results in a new list containing the quotients.

Solution for How to divide each element in a list in Python : You can use a for loop to divide each element in a list Use a for loop to iterate through each element in the list. Use the division operator / to divide by a number. Append the resultant quotients to a new list.

Use a list comprehension for a more compact implementation

quotients = [number / 2 for number in numbers]


how-to-divide-each-element-in-a-list-in-python