To check if number is in range(x,y)
Oscar
jornws200602 at xs4all.nl
Sat Dec 12 10:57:42 EST 2020
In article <slrnrt9neo.40a.Bischoop at vimart.net>,
Bischoop <bischoop at gemail.com> wrote:
>
>I need to check if input number is 1-5. Whatever I try it's not working.
>Here are my aproaches to the problem: https://bpa.st/H62A
>
>What I'm doing wrong and how I should do it?
You need to learn about types. ;-)
Input returns a string. That string is not in the range you compare it
to. You need to convert it to an int:
choice = int(input.. )
This is assuming you want a whole number. You compare it against the
list of numbers [1, 2, 3, 4, 5]. If 2.4 is also a valid number, you need
a different comparison. 2.4 is not in this list.
So first you should get your requirements straight.. ;-)
--
[J|O|R] <- .signature.gz
More information about the Python-list
mailing list