0
How can I divide list's element's by an integer ?
a = [1,4,8,10] / 10 I want this result: [0.1,0.4,0,8,1.0]
3 Réponses
+ 4
Consider using numpy module:
import numpy as np
a = np.array([1,4,8,10]) / 10
print(a)
Or if you really need lists, you have to make calculactions in an iterative way:
a = [x/10 for x in [1, 4, 8, 10]]
print(a)
+ 2
My way not as clever as Kuba.
a = [1,4,8,10]
#I want this result:
#[0.1,0.4,0.8,1.0]
output = []
for i in a:
division = i/10
output.append(division)
print(output)
+ 1
Thank you I want to normalization to list
norm_a = [float(i)/max(i) for i in a]
It's done