Forwarding to python-tutor.
---------- Forwarded message ---------- From: Carmel O'Shannessy <carme...@umich.edu> Date: Thu, Sep 11, 2014 at 12:18 PM Subject: Re: [Tutor] python qn To: Danny Yoo <d...@hashcollision.org> thanks, this worked: times2 = [float(i) for i in times[:2]] On Thu, Sep 11, 2014 at 1:10 PM, Danny Yoo <d...@hashcollision.org> wrote: > > On Thu, Sep 11, 2014 at 8:08 AM, Carmel O'Shannessy <carme...@umich.edu> > wrote: > > > > Hello, > > > > 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]] > > Hi Carmel, > > Do you intend to have a variable named "float.times" here on the left > hand side of the assignment? > > If so, try a different name. What's happening is not variable > assignment, but member assignment. The above statement is saying: > > Take the "float" type, and set its "times" attribute to the right hand > side. > > And that's almost certainly not what you want to do. -- -- Carmel O'Shannessy, Assoc. Prof. Department of Linguistics University of Michigan 440 Lorch Hall 611 Tappan Street Ann Arbor, MI, 48109-1220 Ph: +1 734 764 0353 Fax: +1 734 936 3406 http://www-personal.umich.edu/~carmelos/ _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor