[Tutor] Truckers Log....Me Again

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Sun, 20 Jan 2002 20:53:58 -0800 (PST)


On Sun, 20 Jan 2002, glidedon wrote:

> I am trying to figure out how to do this in a while loop.
> 
> 
> While X is Yes
>     do this
> if X is no
>     do this
> if x is not yes or no
>     print this
>     go back to the beginning of the while loop


It sounds like you want to do something like the following pseudocode

##
while 1:
    read the input x
    if x == yes:
        do this
    elif x == no:
        do the other thing
    else:
        print some warning
###


This is often called a "read-eval-print" loop:

    1.  We read some input from the user.
    2.  We evaluate or interpret that response.
    3.  We print out some output.
    4.  Repeat!

and is often used with interactive programs that need to read input from a
user.


Hope this helps!