Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it?

Ian Kelly ian.g.kelly at gmail.com
Thu Sep 19 19:09:03 EDT 2013


On Thu, Sep 19, 2013 at 1:22 PM, William Bryant <gogobebe2 at gmail.com> wrote:
> It was the other functions above it. Thanks. but I tried to do the while
> loop - I don't think I did it right, I am novice in python and I am 13 years
> old.

It should be structured like this:

    while True:
        answer = input("Enter yes/no:")
        if answer in ('y', 'yes', 'new list'):
            do_yes_stuff()
            break
        elif answer in ('n', 'no', 'close'):
            do_no_stuff()
            break
        else:
            print("Please enter y or n.")

If they answer 'yes' or 'no', then the break statement breaks out of
the while loop.  Otherwise the while loop continues from the top and
asks them again.



More information about the Python-list mailing list