![]() I have divided this article into 4 levels as shown below. I urge you to call on your “virtue of patience” for another 15mins and read on! I promise you will learn a thing or 2 as we have merely scratched the surface! If you feel you have learned everything there is to know about the != operator, then hold your horses! There is plenty more to learn! In simple words, if objects on either side of the “!=” operator are not equal we get True and if they are equal we get False ![]() 3rd line says “is 2 not equal to 2” and as we expected we get False this time!.1st line says “is 1 not equal to 2”, and as expected we get True.In this simple session at the Python interpreter, Here is a simple example Using ‘!=’ to check if 2 integer objects are not-equal to each other > 1 != 2 What is the != operator used for? The “ not equal to” operator is a comparison operator used to compare 2 objects for non-equality. How to read “!= “?The “!=” symbol is called “ not equal to” or “ not equal” for short and is used in many programming languages like C, C++, Python, etc. What is != in python?‘!=’ is an operator in python which is used to compare the non-equality of 2 objects, be it strings or integers or some special user-defined classes Table#1: Python’s “!=” Operator CheatSheet To check if 2 objects are not equal in terms of value The phrase “Practice Makes Perfect” did not survive so many centuries for no reason!įor those of you who came here just to refresh your memories, here is a cheatsheet! Python’s “!=” Operator CheatSheet What is “!=” in Python? ![]() So put on your coding hats, open your laptops and start experimenting and playing with the code shown in the examples as you read them! The best trick to make our brains remember stuff is via active learning. Python is no exception to this rule!Įven though the concepts might look simple, our brains are really good at understanding the concepts but not so good at remembering them! The first step in the journey towards mastery of any programming language is to learn about the various operators provided by that language and learn how to wield them. In this article let us learn about the “!=” operator in Python and learn how to make use of this operator the same way the pros do!
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |