[Tutor] python qn

Peter Otten __peter__ at web.de
Thu Sep 11 19:14:26 CEST 2014


Carmel O'Shannessy wrote:

> times  =  ['50.319468', '50.319468', 't1']
> 
> I want to convert  [0:2] to floats.
> 
> I tried:
> 
> float.times = [float(i) for i in times[:2]]
> 
> but get the error msg:
> 
> TypeError: can't set attributes of built-in/extension type 'float'

Try

times[:2] = [float(s) for s in times[:2]]

PS: What did you expect

> float.times

to achieve?



More information about the Tutor mailing list