Re: [Tutor] repply

2009-01-04 Thread Ole Henning Jensen
prasad rao wrote: hi I got it right. >>> z=[] >>> for x in range(1000): if divmod(x,3)[1]==0:z.append(x) if divmod(x,5)[1]==0:z.append(x) >>> sum(set(z)) 233168 Instead of using the set function you could just use an elif in your for loop. >>> z=[] >>> for x in range(1000):

Re: [Tutor] repply

2009-01-04 Thread Sander Sweers
On Sun, Jan 4, 2009 at 14:18, prasad rao wrote: z=[] for x in range(1000): > if divmod(x,3)[1]==0:z.append(x) > if divmod(x,5)[1]==0:z.append(x) sum(set(z)) > 233168 This can be done in one line of python. >>> sum([x for x in range(1000) if x %3 == 0 or x % 5 == 0]) 233168 Greets

[Tutor] repply

2009-01-04 Thread prasad rao
hi I got it right. >>> z=[] >>> for x in range(1000): if divmod(x,3)[1]==0:z.append(x) if divmod(x,5)[1]==0:z.append(x) >>> sum(set(z)) 233168 I am sorry if this is outside the perimeter of this list. ___ Tutor maillist - Tutor@python.org http://

Re: [Tutor] Repply

2008-12-27 Thread W W
On Sat, Dec 27, 2008 at 3:42 AM, Alan Gauld wrote: > > Its C rather than C++. > The <> in include statements are a variation on the "" which can also be > used. > The differences are subtle and have to do with the search path I think. But > its > been so long since I did serious C/++ I can't recal

Re: [Tutor] Repply

2008-12-27 Thread Alan Gauld
"prasad rao" wrote http://svn.python.org/view/python/trunk/Objects/listobject.c?rev=67498&view=markup Kent ! This is grek and latin to me.From the presence of header files it looks C++.But headerfiles are not between '<' and '>' . Its C rather than C++. The <> in include statements are

[Tutor] Repply

2008-12-26 Thread prasad rao
Thanks for help. > http://svn.python.org/view/python/trunk/Objects/listobject.c?rev=67498&view=markup Kent ! This is grek and latin to me.From the presence of header files it looks C++.But headerfiles are not between '<' and '>' . >But why are you trying to sort in this fashion? Alan Gauld!