Feb 11, 2016 Multiple 'or' condition in Python duplicate Ask Question 17. Browse other questions tagged python conditional-statements multiple-conditions or ask your own question. 5 years, 3 months ago. 65,886 times. 3 years, 4 months ago. Compound statements¶ Compound statements contain (groups of) other statements; they affect or control the execution of those other statements in some way. In general, compound statements span multiple lines, although in simple incarnations a whole compound statement may be contained in one line.
How would you write, in python:
![Multiple Or Statements Python Multiple Or Statements Python](http://www.dummies.com/wp-content/uploads/beginning-programming-with-python-2e-nested-statements.jpg)
I've tried every way I can think of, and am finding it very frustrating.
ZakZak
3 Answers
If
key
isn't an int
or float
but a str
ing, you need to convert it to an int
first by doingor to a
float
by doingOtherwise, what you have in your question should work, but
or
would be a bit clearer.
agfagf120k2828 gold badges235235 silver badges211211 bronze badges
Here's a boolean thing:
but
![Multiple Or Statements Python Multiple Or Statements Python](/uploads/1/2/5/0/125076954/624690154.png)
(not a) or (not b) not ( a and b )
, is false only if a and b are both truenot (a or b)
is true only if a and be are both false.spikeysnackspikeysnack
you can simply use
if (key<1) or (key>34):
your problem will be solved
joginder singhjoginder singh