Python Bytes

A powerful way to check multiple conditions in Python

Swami K
1 min readJun 4, 2022
A powerful way to check multiple conditions in Python

Hey All,

I hope you are all doing well!

Welcome to Python Bytes!

We’ll explore an efficient, stylish, and readable way to check multiple conditions in Python in this byte!

Ready?! Let’s GO!

Code

Here is the code you can dive into for folks who don’t have the patience to watch the video!

Checking multiple conditions using ‘or’ operator

The ‘or’ operator does the job for us, no doubt!

But, as the number of conditions increases, the ‘or’ operator will stretch your ‘if’ statement out, like a train. 🚂

I hope you agree with me on that!

Having said that, now you can ask, what’s the better way, right?!

Let’s explore that!

Here’s a cool way of checking multiple conditions using the ‘in’ operator.

Checking multiple conditions using the ‘in’ operator

That’s it, Folks!

Hope you enjoyed this episode of Python Bytes!

Python Byte Tip Credit — Görkem Arslan, Jonny Jackson & Pylint

This byte was created using Ultron V4’s auto-simulation technology, an AI crafted by Team DevOps at @ Kissflow

Follow me @iSwamiK for more bytes on DevOps Transformation!

Stay tuned!

--

--

Swami K

Senior Director of DevOps & SRE at Kissflow | Integrating Netflix DevOps Culture & Google SRE Practices to Empower Our Engineering Team 🚀🔧