Python
Snippets
.Dev
Archive
Login with GitHub
Chained comparison
You can do multiple comparisons with all kinds of operators in a single line
Python: 3.0
Fatos Morina
03 Jul 2021
0
Login to upvote
1
2
3
a
=
3
print(
2
<
a
<
8
)
# True
print(
1
==
a
<
2
)
# False
a = 3 print( 2 < a < 8) # True print(1 == a < 2) # False
Copy
| Download as:
.py file
PNG
Share on:
FB
Twitter
LinkedIn
WA
Previous
Random Snippet
Next
©2021 - code108labs Contributors Hosted on
DigitalOcean
Partner website:
pythoncircle.com