Re: nested loops

Discussion in 'Python' started by Sven, Feb 26, 2013.

  1. Sven

    Sven Guest

    Here's one solution

    import time
    count_timer = int(raw_input('how many seconds?: '))
    for i in range(count_timer, 0, -1):
    print i,
    print "*" * i
    time.sleep(1)
    print 'blast off!'


    On 25 February 2013 22:46, 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!
    >
    >
    > --
    > http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list>
    >




    --
    ../Sven
     
    Sven, Feb 26, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Allan Bruce

    dynamic number of nested loops

    Allan Bruce, Jul 1, 2004, in forum: Java
    Replies:
    5
    Views:
    9,918
    Tor Iver Wilhelmsen
    Jul 3, 2004
  2. Porthos
    Replies:
    3
    Views:
    498
    Joris Gillis
    Feb 7, 2005
  3. SplaTTer
    Replies:
    2
    Views:
    399
    SplaTTer
    Jul 2, 2003
  4. viza

    break or continue out of nested loops

    viza, Jul 16, 2003, in forum: C Programming
    Replies:
    5
    Views:
    1,058
    sunil
    Jul 17, 2003
  5. Me
    Replies:
    2
    Views:
    264
Loading...

Share This Page