[Tutor] recursive?

Ole Jensen learning.python at dbmail.dk
Sat Sep 13 23:53:35 EDT 2003


> condition. after typing y after 'do you want try again?' how I can start
> again all the program, asking again the three values?

When you want to do the same thing over and over agian, you need to tell the
computer to *loop* through that code. I'ld suggest you read up on it in some
online tutorials, personally I'll recomend Josh Cogliati's online tutorial,
you can find it here: http://www.honors.montana.edu/~jjc/easytut/easytut/

But I'm gonna give you a tip more as an example of what you might want to
do:

>>> again = 1 # We need a value to start the loop.
>>> while again == 1: # While 'again' is one keep redoing the indented part
    print "Add two numbers"
    a = input("State the 1'st number: ")
    b = input("State the 2'nd number: ")
    print "The sum is:", a+b
    again = input("Press '1' to keep on adding") # if not then press
    #
something else!

Bye for now
Olé




More information about the Tutor mailing list