Thanks to all of you...Dave On Feb 7, 3:23 pm, Alex Ghitza <aghi...@gmail.com> wrote: > On Sun, 7 Feb 2010 15:17:08 -0800 (PST), davedo2 <dave...@gmail.com> wrote: > > I want to run a range of numbers through the factor() function and if > > I run a loop through a list as in: > > for i in [25,37,205]: > > print i.factor() > > it works fine, but if I try > > for i in range(1,5): > > print i.factor() > > I get the error message 'int' object has no attribute 'factor' - how > > do I get > > factor() to work with a range? Thanks...Dave > > range() returns Python integers, which do not have a factor() method. > You need to get Sage integers instead, so use srange() or xsrange(): > > sage: srange(5) > [0, 1, 2, 3, 4] > sage: type(srange(5)[2]) > <type 'sage.rings.integer.Integer'> > sage: for i in srange(1, 5): > print i.factor() > 1 > 2 > 3 > 2^2 > > Best, > Alex > > -- > Alex Ghitza -- Lecturer in Mathematics -- The University of Melbourne > -- Australia --http://www.ms.unimelb.edu.au/~aghitza/
-- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org