Trick To Simplify IF In Python

Using conditionals or say IF-ELSE statement is quite common when developing any application and based on the programming language, the syntax to handle such conditionals varies but the underline concept remains the same.

In this article, I’ll show you how to write an IF statement in Python to check if a given item is present in the collection or not.

Have a look at the traditional way to achieve the same:

fruits = [‘apple’,’orange’,’banana’,’mango’]

fruit = ‘mango’

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store