Software engineering and personal development

Month: August 2022

How to Quickly Simply “if” Statements in Python

There can be cases when we want to check whether a value is equal to one of the multiple other values.

One way that someone may start using is using or and adding multiple checks. For example, let us say that we want to check whether a number is 11, 55, or 77. Your immediate response may be to do the following:

 m = 1
 ​
 if m == 11 or m == 55 or m == 77:
     print("m is equal to 11, 55, or 77")

There is fortunately another quick way to do that.

Continue reading

© 2024 Fatos Morina

Theme by Anders NorenUp ↑