Dan Sommers wrote:
> On 27 Apr 2006 02:48:46 -0700,
> [EMAIL PROTECTED] wrote:
>
> > why the output of this code :
> > x = 0
> > while x < 10:
> >         z = 0
> >         print x
> >         x = x + 1
> >         while z < x:
> >                 print z,
> >                 z = z + 1
>
> > is
>
> > 0
>
> Okay, that was x, from the print statement inside the x-loop.
>
> > 0 1
>
> And that's z, from the print statement inside the z-loop.  z is 0, and
> then when z is 1, it's not less than x, so we're done printing z's.
>
> And then we get the next x.
>
> > 0 1 2
>
> And two more z's, 0 and 1, since x is now 2.
>
> And another x.
>
> Since this might be homework, I'll stop at a hint:  you need to think
> about when you want each printed line to end, and make sure that you
> tell python to end it there.
>
> Regards,
> Dan
>
> --
> Dan Sommers
> <http://www.tombstonezero.net/dan/>
> "I wish people would die in alphabetical order." -- My wife, the genealogist


thanks..solved...just removed the print x..

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to