{"id":3433,"date":"2020-07-04T14:12:14","date_gmt":"2020-07-04T08:42:14","guid":{"rendered":"http:\/\/www.pythonpool.com\/?p=3433"},"modified":"2024-01-01T12:25:07","modified_gmt":"2024-01-01T06:55:07","slug":"not-in-python","status":"publish","type":"post","link":"https:\/\/www.pythonpool.com\/not-in-python\/","title":{"rendered":"Not in Python | With Uses and In-Depth Explanation"},"content":{"rendered":"\n<p>Python, being a user-friendly language, allows us to use many English words. One such keyword is  &#8216;not&#8217;. It is a very crucial keyword, having many use-cases as various operators. For example, it can be used as a<strong> logical operator to combine conditional statements.<\/strong> Not only as a logical operator but also not in Python, it can be used as<strong> &#8216;is not an identity and as &#8216;not in&#8217; in the membership operator.\u00a0\u00a0<\/strong><\/p>\n\n\n\n<p>Identity operators are generally used to compare the objects, whether they are equal and in the same memory location or not. A membership operator is used to test whether a particular sequence is present in the object.\u00a0<\/p>\n\n\n\n<p>Let us understand every use case of the &#8216;not&#8217; keyword in Python.\u00a0<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_74 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #990303;color:#990303\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #990303;color:#990303\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.pythonpool.com\/not-in-python\/#3_Unique_Forms_of_Not_in_Python\" >3 Unique Forms of Not in Python<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.pythonpool.com\/not-in-python\/#1_Not_in_Python_as_a_Logical_Operator\" >1. Not in Python&nbsp;as a Logical Operator<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.pythonpool.com\/not-in-python\/#2_Not_in_Python_as_a_Membership_operator\" >2. Not in Python&nbsp;as a Membership operator&nbsp;<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.pythonpool.com\/not-in-python\/#3_Not_in_Python_As_an_Identity_Operator\" >3. Not in Python\u00a0As an Identity Operator\u00a0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.pythonpool.com\/not-in-python\/#Also_Read\" >Also Read:<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.pythonpool.com\/not-in-python\/#Conclusion\" >Conclusion-&nbsp;<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-3-unique-forms-of-not-in-python\"><span class=\"ez-toc-section\" id=\"3_Unique_Forms_of_Not_in_Python\"><\/span>3 Unique Forms of Not in Python<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>As a Logical Operator<\/li>\n\n\n\n<li>As a Membership Operator<\/li>\n\n\n\n<li>Identity Operator<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-1-not-in-python-as-a-logical-operator\"><span class=\"ez-toc-section\" id=\"1_Not_in_Python_as_a_Logical_Operator\"><\/span>1. Not in Python&nbsp;as a Logical Operator<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Logical operators are used for combining conditional statements. There are three types of logical operators &#8211; <strong>&#8216;and,&#8217; &#8216;or&#8217; and &#8216;not.&#8217;&nbsp;&nbsp;<\/strong><\/p>\n\n\n\n<p>&#8216;not&#8217; is a case\u2013sensitive keyword and only returns <strong>Boolean values (True or False)<\/strong>. It returns the reverse of the original result, i.e., if the first output was coming to be True, &#8216;not&#8217; will convert it into False and vice versa.&nbsp;<\/p>\n\n\n\n<p>Let&#8217;s understand it with an example, and then we will discuss it in detail.&nbsp;&nbsp;<\/p>\n\n\n\n<p>Without \u2018not\u2019\u2019-&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>x=5&nbsp;\ny=2&nbsp;\nif (x&gt;y):&nbsp;\n&nbsp; &nbsp;print(x)&nbsp;\nelse:&nbsp;\n&nbsp;&nbsp;print(y)&nbsp;\n\nOutput-\n5&nbsp;<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1586\" height=\"532\" src=\"https:\/\/i2.wp.com\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-71.png?fit=1024%2C343&amp;ssl=1\" alt=\"\" class=\"wp-image-3439\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-71.png 1586w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-71-300x101.png 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-71-1024x343.png 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-71-768x258.png 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-71-1536x515.png 1536w\" sizes=\"(max-width: 1586px) 100vw, 1586px\" \/><\/figure>\n\n\n\n<p><strong>Now, let us use the \u2018not\u2019 keyword\u00a0 \u00a0<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>x=5&nbsp;\ny=2&nbsp;\n#Here, x&gt;y and it would have return True but due to \u2018not\u2019 it returned as False.&nbsp;\nif not(x&gt;y):&nbsp;\n&nbsp; &nbsp;print(x)&nbsp;\nelse:&nbsp;\n&nbsp; &nbsp;print(y)&nbsp;\n\nOutput-\n2&nbsp;<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1586\" height=\"532\" src=\"https:\/\/i1.wp.com\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-66.png?fit=1024%2C343&amp;ssl=1\" alt=\"not in python\" class=\"wp-image-3434\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-66.png 1586w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-66-300x101.png 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-66-1024x343.png 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-66-768x258.png 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-66-1536x515.png 1536w\" sizes=\"(max-width: 1586px) 100vw, 1586px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-let-us-make-a-program-to-make-a-list-empty-and-see-where-not-can-be-used\">Let us make a program to make a list empty and see where \u2018not\u2019 can be used.&nbsp;<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>empty=False&nbsp;\nlist1=&#91;1,2,3,4,5,6,6,7,8,9,10]&nbsp;\nprint(\"list before\",list1)&nbsp;\n# not empty means 'TRUE'&nbsp;\nwhile (not empty):&nbsp;\n&nbsp; &nbsp;# while the list1 is not empty&nbsp;\n&nbsp; &nbsp;if list1 !=&#91;]:&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;list1.pop()&nbsp; &nbsp;\n&nbsp; &nbsp;else:&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp;empty=True&nbsp;\nprint(\"list after\",list1)&nbsp;\n\nOutput-&nbsp;\nlist before &#91;1, 2, 3, 4, 5, 6, 6, 7, 8, 9, 10]&nbsp;\nlist after &#91;]&nbsp;<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1586\" height=\"676\" src=\"https:\/\/i2.wp.com\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-67.png?fit=1024%2C436&amp;ssl=1\" alt=\"not in python\" class=\"wp-image-3435\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-67.png 1586w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-67-300x128.png 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-67-1024x436.png 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-67-768x327.png 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-67-1536x655.png 1536w\" sizes=\"(max-width: 1586px) 100vw, 1586px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-2-not-in-python-as-a-membership-operator\"><span class=\"ez-toc-section\" id=\"2_Not_in_Python_as_a_Membership_operator\"><\/span>2. Not in Python&nbsp;as a Membership operator&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>A very common use-case of not in any programming language, which you may have used often, is &#8216;not in.&#8217; We use it to determine whether a <strong>particular sequence is in an object or not.<\/strong>\u00a0<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-suppose-we-want-to-check-whether-peas-is-in-the-list-of-fruits-or-not\">Suppose we want to check whether \u2018peas\u2019 is in the list of fruits or not.\u00a0<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>fruits=&#91;\"mango\",\n        \"apple\",\n        \"banana\",\n        \"strawberry\",\n        \"pineapple\",\n        \"melon\"]&nbsp;\nif 'peas' not in fruits:&nbsp;\n&nbsp; &nbsp;print(\"Vegetable\")&nbsp;\nelse:&nbsp;\n&nbsp; &nbsp;print(\"Fruit\")&nbsp;\n\nOutput-&nbsp;\nVegetable&nbsp;<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1584\" height=\"628\" src=\"https:\/\/i2.wp.com\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-68.png?fit=1024%2C406&amp;ssl=1\" alt=\"not not in python as membership operator\" class=\"wp-image-3436\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-68.png 1584w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-68-300x119.png 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-68-1024x406.png 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-68-768x304.png 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-68-1536x609.png 1536w\" sizes=\"(max-width: 1584px) 100vw, 1584px\" \/><\/figure>\n\n\n\n<p><strong>To make it shorter and sweeter, We can use these operators to be used inside the print().&nbsp;<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ages=[]&nbsp;\n# making a list of all ages allowed to vote&nbsp;\nfor i in range(18,101):&nbsp;\n&nbsp; &nbsp;&nbsp;ages.append(i)&nbsp;\n# If the given age is not allowed to vote print True&nbsp;\nprint(17 not in ages)&nbsp;\n\nOutput-&nbsp;\nTrue&nbsp;<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1586\" height=\"580\" src=\"https:\/\/i2.wp.com\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-75.png?fit=1024%2C374&amp;ssl=1\" alt=\"\" class=\"wp-image-3443\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-75.png 1586w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-75-300x110.png 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-75-1024x374.png 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-75-768x281.png 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-75-1536x562.png 1536w\" sizes=\"(max-width: 1586px) 100vw, 1586px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-program-to-list-down-marks-in-a-list-and-add-absent-if-name-not-in-the-dictionary\">Program to List down marks in a list and add \u2018Absent\u2019 if name not in the dictionary&nbsp;<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">dict1={\"Ashwini\":48,\n       \"khush\":41,\n       \"Lamba\":49,\n       \"Shera\":30,\n       \"Arjun\":47}&nbsp;\nlist1=['Ashwini','Shalu','khush','Shabnam','Lamba','Manish']&nbsp;\nlist2=[]&nbsp;\nfor i in list1:&nbsp;\n&nbsp; &nbsp;if i not in dict1.keys():&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp;list2.append(\"Absent\")&nbsp;\n&nbsp; &nbsp;else:&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp;list2.append(dict1[i])&nbsp;\nprint(list2)&nbsp;\n\nOutput-&nbsp;\n[48, 'Absent', 41, 'Absent', 49, 'Absent']&nbsp;<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1584\" height=\"772\" src=\"https:\/\/i1.wp.com\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-69.png?fit=1024%2C499&amp;ssl=1\" alt=\"\" class=\"wp-image-3437\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-69.png 1584w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-69-300x146.png 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-69-1024x499.png 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-69-768x374.png 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-69-1536x749.png 1536w\" sizes=\"(max-width: 1584px) 100vw, 1584px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-let-s-create-a-very-small-login-system-using-not-in-keyword\">Let\u2019s create a very small login system using \u2018not in\u2019 keyword&nbsp;<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>password_iscorrect=False&nbsp;\nlogin={'ashwini':'mandani'}&nbsp;\nwhile(not password_iscorrect):&nbsp;\n&nbsp; &nbsp;username=input(\"Enter username \")&nbsp;\n&nbsp; &nbsp;password=input(\"Enter password \")&nbsp;\n&nbsp; &nbsp;if username in login.keys() and password not in login.values():&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp;password=input(\"Incorrect!! Enter correct password\")&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;password_iscorrect=False&nbsp;\n&nbsp; &nbsp;else:&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;print(\"Welcome \",username)&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;password_iscorrect=True&nbsp;\nOutput-&nbsp;\nEnter username ashwini&nbsp;\nEnter password mandani&nbsp;\nWelcome ashwini&nbsp;&nbsp;<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1586\" height=\"772\" src=\"https:\/\/i2.wp.com\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-73.png?fit=1024%2C498&amp;ssl=1\" alt=\"\" class=\"wp-image-3441\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-73.png 1586w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-73-300x146.png 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-73-1024x498.png 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-73-768x374.png 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-73-1536x748.png 1536w\" sizes=\"(max-width: 1586px) 100vw, 1586px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-3-not-in-python-as-an-identity-operator\"><span class=\"ez-toc-section\" id=\"3_Not_in_Python_As_an_Identity_Operator\"><\/span>3. Not in Python\u00a0As an Identity Operator\u00a0<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Identity operators are used to compare objects. We have the &#8216;is not&#8217; <a aria-label=\"undefined (opens in a new tab)\" href=\"https:\/\/www.w3schools.com\/python\/python_operators.asp\" target=\"_blank\" rel=\"noreferrer noopener\">operator<\/a> in Python for this purpose.\u00a0\u00a0<\/p>\n\n\n\n<p>Program to divide list1 from list2, but if any element in list2=0 (<strong>Denominator cannot be equal to &#8216;0&#8217;<\/strong>).&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>list1=&#91;27,14,15,60,1,8]&nbsp;\nlist2=&#91;9,7,5,15,0,16]&nbsp;\nlist3=&#91;]&nbsp;\nfor i in range(len(list1)):&nbsp;\n&nbsp; &nbsp;#Denominator cannot be 0&nbsp;\n&nbsp; &nbsp;if list2&#91;i] is not 0:&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp;list3.append(list1&#91;i]\/list2&#91;i])&nbsp;\n&nbsp; &nbsp;else:&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp;list3.append(\"Not Possible\")&nbsp;\nprint(list3)&nbsp;\n\nOutput-&nbsp;\n&#91;3.0, 2.0, 3.0, 4.0, 'Not Possible', 0.5]&nbsp;<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1584\" height=\"676\" src=\"https:\/\/i0.wp.com\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-70.png?fit=1024%2C437&amp;ssl=1\" alt=\"Identity operator\" class=\"wp-image-3438\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-70.png 1584w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-70-300x128.png 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-70-1024x437.png 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-70-768x328.png 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-70-1536x656.png 1536w\" sizes=\"(max-width: 1584px) 100vw, 1584px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-another-example-can-be-if-we-want-to-sort-elements-on-the-basis-of-type-we-can-use-is-not\">Another example can be if we want to sort elements on the basis of type, we can use is not.&nbsp;<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>list1=&#91;210.2,100,122,199.99,88,17.1,111,88,33.1,1011]&nbsp;\n# list containing integers&nbsp;\nint_list=&#91;]&nbsp;\n# list containing float values&nbsp;\nfloat_list=&#91;]&nbsp;\nfor i in list1:&nbsp;\n&nbsp; &nbsp;# if the data type of&nbsp;&nbsp;\n&nbsp; &nbsp;if type(i) is not int:&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;float_list.append(i)&nbsp;\n&nbsp; &nbsp;else:&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;int_list.append(i)&nbsp;\nprint(\"float list\",float_list)&nbsp;\nprint(\"integer list\",int_list)&nbsp;\n\nOutput-&nbsp;\nfloat list &#91;210.2, 199.99, 17.1, 33.1]&nbsp;\ninteger list &#91;100, 122, 88, 111, 88, 1011]&nbsp;<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1586\" height=\"868\" src=\"https:\/\/i2.wp.com\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-74.png?fit=1024%2C560&amp;ssl=1\" alt=\"Not in Python\u00a0As an Identity Operator\u00a0\" class=\"wp-image-3442\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-74.png 1586w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-74-300x164.png 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-74-1024x560.png 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-74-768x420.png 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-74-1536x841.png 1536w\" sizes=\"(max-width: 1586px) 100vw, 1586px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-also-read\"><span class=\"ez-toc-section\" id=\"Also_Read\"><\/span><strong>Also Read:<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p><a href=\"http:\/\/www.pythonpool.com\/python-remove-duplicates-from-list\/\">Python Remove Duplicates From List<\/a><br><a href=\"http:\/\/www.pythonpool.com\/python-print-without-newline\/\">Python Print Without Newline<\/a><br><a href=\"http:\/\/www.pythonpool.com\/learn-python-the-hard-way-pdf\/\">Learn Python the Hard Way Review PDF<\/a><br><a href=\"http:\/\/www.pythonpool.com\/python-map-function\/\">Python Map<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion-&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>We have seen many examples of using not in Python in many different ways. In many places, we could have used &#8216;!=.&#8217; instead of not a keyword.<strong> But the primary purpose of including these types of keywords in Python is to make it more user friendly by adding more English words.<\/strong> So, we must use these types of keywords to encourage the primary purpose behind the language.\u00a0\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python, being a user-friendly language, allows us to use many English words. One such keyword is &#8216;not&#8217;. It is a very crucial keyword, having many &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Not in Python | With Uses and In-Depth Explanation\" class=\"read-more button\" href=\"https:\/\/www.pythonpool.com\/not-in-python\/#more-3433\" aria-label=\"More on Not in Python | With Uses and In-Depth Explanation\">Read more<\/a><\/p>\n","protected":false},"author":3,"featured_media":3478,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[15],"tags":[1256,1263,1277,1271,1257,1259,1264,1275,1260,1270,1262,1274,1258,1276,1278,1268,1265,1269,1255,1266,1261,1272,1273,1267],"class_list":["post-3433","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-does-not-equal-in-python","tag-how-do-you-say-not-in-python","tag-how-to-do-not-equal-in-python","tag-how-to-use-not-in-python","tag-if-not-in-list-python","tag-if-not-in-python","tag-is-not-in-python","tag-not-equal-in-python","tag-not-equal-sign-in-python","tag-not-equal-to-in-python","tag-not-equal-to-sign-in-python","tag-not-equals-in-python","tag-not-in-list-python","tag-not-in-python","tag-not-operator-in-python","tag-python-if-not-in","tag-python-if-not-in-list","tag-python-is-not-in","tag-python-not-in","tag-python-not-in-dictionary","tag-python-not-in-list","tag-python-not-in-string","tag-python-not-recognized-in-cmd","tag-ssl-module-in-python-is-not-available","infinite-scroll-item"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.1 (Yoast SEO v25.0) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Not in Python | With Uses and In-Depth Explanation - Python Pool<\/title>\n<meta name=\"description\" content=\"Not in Python is a keyword which is used as a logical operator. In Python, Not keyword will return True if the expression is false and vice-versa.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pythonpool.com\/not-in-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Not in Python | With Uses and In-Depth Explanation\" \/>\n<meta property=\"og:description\" content=\"Python, being a user-friendly language, allows us to use many English words. One such keyword is &#039;not&#039;. It is a very crucial keyword, having many\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pythonpool.com\/not-in-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Pool\" \/>\n<meta property=\"article:published_time\" content=\"2020-07-04T08:42:14+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-01T06:55:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/Capture.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1003\" \/>\n\t<meta property=\"og:image:height\" content=\"601\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Ashwini Mandani\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:site\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ashwini Mandani\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.pythonpool.com\/not-in-python\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/not-in-python\/\"},\"author\":{\"name\":\"Ashwini Mandani\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/8a75fb48eb1f3dc952df65a8c28ac056\"},\"headline\":\"Not in Python | With Uses and In-Depth Explanation\",\"datePublished\":\"2020-07-04T08:42:14+00:00\",\"dateModified\":\"2024-01-01T06:55:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/not-in-python\/\"},\"wordCount\":528,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/not-in-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/Capture.jpg\",\"keywords\":[\"does not equal in python\",\"how do you say not in python\",\"how to do not equal in python\",\"how to use not in python\",\"if not in list python\",\"if not in python\",\"is not in python\",\"not equal in python\",\"not equal sign in python\",\"not equal to in python\",\"not equal to sign in python\",\"not equals in python\",\"not in list python\",\"not in python\",\"not operator in python\",\"python if not in\",\"python if not in list\",\"python is not in\",\"python not in\",\"python not in dictionary\",\"python not in list\",\"python not in string\",\"python not recognized in cmd\",\"ssl module in python is not available\"],\"articleSection\":[\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.pythonpool.com\/not-in-python\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.pythonpool.com\/not-in-python\/\",\"url\":\"https:\/\/www.pythonpool.com\/not-in-python\/\",\"name\":\"Not in Python | With Uses and In-Depth Explanation - Python Pool\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/not-in-python\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/not-in-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/Capture.jpg\",\"datePublished\":\"2020-07-04T08:42:14+00:00\",\"dateModified\":\"2024-01-01T06:55:07+00:00\",\"description\":\"Not in Python is a keyword which is used as a logical operator. In Python, Not keyword will return True if the expression is false and vice-versa.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.pythonpool.com\/not-in-python\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.pythonpool.com\/not-in-python\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/not-in-python\/#primaryimage\",\"url\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/Capture.jpg\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/Capture.jpg\",\"width\":1003,\"height\":601,\"caption\":\"not in python\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.pythonpool.com\/not-in-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.pythonpool.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Not in Python | With Uses and In-Depth Explanation\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.pythonpool.com\/#website\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"name\":\"Python Pool\",\"description\":\"Your One-Stop Python Learning Destination\",\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.pythonpool.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.pythonpool.com\/#organization\",\"name\":\"Python Pool\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"contentUrl\":\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"width\":452,\"height\":185,\"caption\":\"Python Pool\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/pythonpool\",\"https:\/\/www.youtube.com\/c\/pythonpool\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/8a75fb48eb1f3dc952df65a8c28ac056\",\"name\":\"Ashwini Mandani\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f765ed1940ac0ae1d30ce4cb2f1452c1e83143b07354d25a42c1cd118980e269?s=96&d=wavatar&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f765ed1940ac0ae1d30ce4cb2f1452c1e83143b07354d25a42c1cd118980e269?s=96&d=wavatar&r=g\",\"caption\":\"Ashwini Mandani\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Not in Python | With Uses and In-Depth Explanation - Python Pool","description":"Not in Python is a keyword which is used as a logical operator. In Python, Not keyword will return True if the expression is false and vice-versa.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pythonpool.com\/not-in-python\/","og_locale":"en_US","og_type":"article","og_title":"Not in Python | With Uses and In-Depth Explanation","og_description":"Python, being a user-friendly language, allows us to use many English words. One such keyword is 'not'. It is a very crucial keyword, having many","og_url":"https:\/\/www.pythonpool.com\/not-in-python\/","og_site_name":"Python Pool","article_published_time":"2020-07-04T08:42:14+00:00","article_modified_time":"2024-01-01T06:55:07+00:00","og_image":[{"width":1003,"height":601,"url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/Capture.jpg","type":"image\/jpeg"}],"author":"Ashwini Mandani","twitter_card":"summary_large_image","twitter_creator":"@pythonpool","twitter_site":"@pythonpool","twitter_misc":{"Written by":"Ashwini Mandani","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pythonpool.com\/not-in-python\/#article","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/not-in-python\/"},"author":{"name":"Ashwini Mandani","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/8a75fb48eb1f3dc952df65a8c28ac056"},"headline":"Not in Python | With Uses and In-Depth Explanation","datePublished":"2020-07-04T08:42:14+00:00","dateModified":"2024-01-01T06:55:07+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pythonpool.com\/not-in-python\/"},"wordCount":528,"commentCount":0,"publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"image":{"@id":"https:\/\/www.pythonpool.com\/not-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/Capture.jpg","keywords":["does not equal in python","how do you say not in python","how to do not equal in python","how to use not in python","if not in list python","if not in python","is not in python","not equal in python","not equal sign in python","not equal to in python","not equal to sign in python","not equals in python","not in list python","not in python","not operator in python","python if not in","python if not in list","python is not in","python not in","python not in dictionary","python not in list","python not in string","python not recognized in cmd","ssl module in python is not available"],"articleSection":["Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pythonpool.com\/not-in-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pythonpool.com\/not-in-python\/","url":"https:\/\/www.pythonpool.com\/not-in-python\/","name":"Not in Python | With Uses and In-Depth Explanation - Python Pool","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pythonpool.com\/not-in-python\/#primaryimage"},"image":{"@id":"https:\/\/www.pythonpool.com\/not-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/Capture.jpg","datePublished":"2020-07-04T08:42:14+00:00","dateModified":"2024-01-01T06:55:07+00:00","description":"Not in Python is a keyword which is used as a logical operator. In Python, Not keyword will return True if the expression is false and vice-versa.","breadcrumb":{"@id":"https:\/\/www.pythonpool.com\/not-in-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pythonpool.com\/not-in-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/not-in-python\/#primaryimage","url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/Capture.jpg","contentUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/Capture.jpg","width":1003,"height":601,"caption":"not in python"},{"@type":"BreadcrumbList","@id":"https:\/\/www.pythonpool.com\/not-in-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pythonpool.com\/"},{"@type":"ListItem","position":2,"name":"Not in Python | With Uses and In-Depth Explanation"}]},{"@type":"WebSite","@id":"https:\/\/www.pythonpool.com\/#website","url":"https:\/\/www.pythonpool.com\/","name":"Python Pool","description":"Your One-Stop Python Learning Destination","publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pythonpool.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.pythonpool.com\/#organization","name":"Python Pool","url":"https:\/\/www.pythonpool.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/","url":"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","contentUrl":"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","width":452,"height":185,"caption":"Python Pool"},"image":{"@id":"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/pythonpool","https:\/\/www.youtube.com\/c\/pythonpool"]},{"@type":"Person","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/8a75fb48eb1f3dc952df65a8c28ac056","name":"Ashwini Mandani","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/f765ed1940ac0ae1d30ce4cb2f1452c1e83143b07354d25a42c1cd118980e269?s=96&d=wavatar&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f765ed1940ac0ae1d30ce4cb2f1452c1e83143b07354d25a42c1cd118980e269?s=96&d=wavatar&r=g","caption":"Ashwini Mandani"}}]}},"_links":{"self":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/3433","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/comments?post=3433"}],"version-history":[{"count":8,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/3433\/revisions"}],"predecessor-version":[{"id":31461,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/3433\/revisions\/31461"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media\/3478"}],"wp:attachment":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media?parent=3433"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/categories?post=3433"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/tags?post=3433"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}