[Tutor] NEWBIE- how to make a program continue

Sheila King sheila@thinkspot.net
Wed, 20 Feb 2002 06:37:00 -0800


On Wed, 20 Feb 2002 09:25:10 -0500, "Robert Garber"
<garber@centralcatholic.org>  wrote about [Tutor] NEWBIE- how to make a
program continue:

> I am very NEW to programing. Here is my question. I have written 
> a small program( with the help of teaching python in 24 hours) I 
> added the year = input line it works well except i want it to countue 
> doing what it does utill i tell it to stop. How do I do this?
> 

You want a loop. Try something like this:

def julian_leap (y) :
    if (y%4) == 0:
        return 1
    return 0

while 1:
    year = input ( " Type in a year:" )
    if julian_leap (year):
        print year, "is leap"
    else:
        print year, "is not a leap year"
    again = raw_input( "Do another ? (y/n) ")
    if again == 'n':
        break


-- 
Sheila King
http://www.thinkspot.net/sheila/

"When introducing your puppy to an adult cat,
restrain the puppy, not the cat." -- Gwen Bailey,
_The Perfect Puppy: How to Raise a Well-behaved Dog_