. Advertisement .
..3..
. Advertisement .
..4..
Please let me ask, assuming I have a sequence of numbers, How to Divide All The Numbers Of A List By One Number Python?
Ideas for “Divide All The Numbers Of A List By One Number Python”:
Python is an interpreted, interactive and object-oriented programming language. It provides powerful data structures such as lists, dictionaries, and sets and has a clear syntax that allows programmers to easily write complex code in short programs. To Divide All The Numbers Of A List By One Number Python, You can use stynax below:
myList[:] = [x / myInt for x in myList]
For example, you want to divide every number in your_list by some number, let’s usage using list comprehension:
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]
If anyone do not want to look for a perfect solution so you can also use following way