nested loops
Alister
alister.ware at ntlworld.com
Tue Feb 26 09:36:40 EST 2013
On Mon, 25 Feb 2013 23:46:11 +0100, leonardo wrote:
> hi everyone,
>
> i have the following program:
>
> import time count_timer = int(raw_input('how many seconds?: '))
> for i in range(count_timer, 0, -1):
> print i time.sleep(1)
> print 'blast off!'
>
>
> this is the result:
>
> how many seconds?: 5 5
> 4
> 3
> 2
> 1
> blast off!
>
> how can i have it print a row of stars beside each number, like this?:
>
> how many seconds?: 5 5 * * * * *
> 4 * * * *
> 3 * * *
> 2 * *
> 1 *
> blast off!
you could try simply changing your print statement to
print "%s %s"%(i,"*" * i)
:-)
--
Someone in DAYTON, Ohio is selling USED CARPETS to a SERBO-CROATIAN
More information about the Python-list
mailing list