[Tutor] trivial simple program..can it be made more concise?

Joel Goldstick joel.goldstick at gmail.com
Sat Feb 14 04:49:42 CET 2015


On Fri, Feb 13, 2015 at 10:17 PM, <steve10brink at comcast.net> wrote:

> Hi all,
>
> I was playing with Python tonight and created a simple program that
> outputs numbers counting up then counting down all on the same terminal
> line. The code is as follows:
>
>
>
> #------------------------------------------------------------
> a = 320000 #number to count up to
>
>
> for i in range (a):
> print i, '\r',
>
> for i in range ((a-1),0,-1):
> print i, '\r',
>
> #------------------------------------------------------------
>
>
>
>
> It works as desired. However, I was trying to figure out a way to make it
> more concise but
>
> cannot see a way since the 'range' parameters must be integers (no
> functions allowed?).
>
>
>
>
> Anyone see a way to simplify it?
>
>
> you don't need the \r.  print will print each line on a new line

>
>
> Thanks,
>
> Steve
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>



-- 
Joel Goldstick
http://joelgoldstick.com


More information about the Tutor mailing list