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

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -