how to divide each element in a list python code example
Example 1: python divide every element in a list by a number
# Example usage using list comprehension:
# Say you want to divide every number in your_list by some number
your_list = [10,20,30,40,50,60,70,80,90]
new_list = [x / 10 for item in your_list]
print(new_list)
--> [1,2,3,4,5,6,7,8,9] # Each number divided by 10
Example 2: divide all elements of list by an integer
myList[:] = [x / myInt for x in myList]