floating point - Python array multiply -
hh=[[82.5], [168.5]] n=1./5 ll=n*hh
what i'm doing wrong? received error :
"can't multiply sequence non-int of type 'float'"
i try add float(), not solve problem;
i need multiply each element in array... all
**ok idea number * array, how multiply array*array, tried same number*array, have problems:
edit 2:**
hh=[[82.5], [168.5]] n=zip(*hh) ll = [[x*n x in y] y in hh]
???
when multiply sequence x
in python, doesn't multiply each member of sequence - repeat sequence x
times. that's why x has integer (it can't float).
what want use list comprehension:
hh = [[82.5], [168.5]] n = 1.0 / 5 ll = [[x*n x in y] y in hh]
Comments
Post a Comment