Problems with scripts

Wildman best_lay at yahoo.com
Mon Feb 13 13:53:04 EST 2017


On Mon, 13 Feb 2017 10:08:11 -0800, Lauren Fugate wrote:

> So I tried both of these and they didn't change anything, the python shell printed the same things...

The first assignment is overly complicated.  The extra input functions are
useless.  There is no loopback to check the input.  Also, input returns
a string not an int or float.  Try this:

x = ["17","18","19","20"]
answer = None
print("How old are you: 17, 18, 19, or 20?")
while answer not in x:
    answer = input("> ")
    if answer in x:
        print("Wow, you are old!")
    else:
        print("You just can't follow drections, can you? Choose either 17, 18, 19, or 20.")

Keep in mind that the above code does not give you a way out.
One of the expected numbers must be entered.

I'll leave the second one for you to figure out.

-- 
<Wildman> GNU/Linux user #557453
The cow died so I don't need your bull!



More information about the Python-list mailing list