what if I have more than 1 condition to satisfy and get the output same for all the conditions. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

what if I have more than 1 condition to satisfy and get the output same for all the conditions.

.Eg: if 5<10 and 5>2 and 5 is an odd number my output should be 5 is a valid number. Please help with this doubt.

9th Aug 2021, 4:27 PM
Tharun
Tharun - avatar
8 Answers
+ 3
You can do that in this way: x = int(input()) if x < 10 and x > 2 and x % 2 != 0: print("this is true")
9th Aug 2021, 4:37 PM
JaScript
JaScript - avatar
+ 3
Please first save your attempt on SL Playground and link here.
9th Aug 2021, 4:40 PM
JaScript
JaScript - avatar
+ 1
Tharun How about this one? :- if 2 < x < 10 and x & 1: print("valid") # Hope this helps
9th Aug 2021, 5:14 PM
Calvin Thomas
Calvin Thomas - avatar
+ 1
if(num>2 && num<10 && num%2!=0)
10th Aug 2021, 3:15 PM
Rithanya
Rithanya - avatar
0
You can chain the condition with 'and', 'or'. 'and' you need to have 2 or more conditions being satisfied.
9th Aug 2021, 4:33 PM
你知道規則,我也是
你知道規則,我也是 - avatar
0
Iam unable to do it on my mobile
9th Aug 2021, 4:49 PM
Tharun
Tharun - avatar
0
I will share the link later.Thank u all
9th Aug 2021, 4:50 PM
Tharun
Tharun - avatar
- 3
Can u please give me the answer for flipbuzz challenge in control structures lesson
9th Aug 2021, 4:38 PM
Tharun
Tharun - avatar