{"id":1473,"date":"2023-05-21T08:25:21","date_gmt":"2023-05-21T08:25:21","guid":{"rendered":"https:\/\/itnotes.apjsoftwares.com\/?p=1473"},"modified":"2023-05-21T08:25:21","modified_gmt":"2023-05-21T08:25:21","slug":"explain-membership-operators-with-example","status":"publish","type":"post","link":"https:\/\/itnotes.apjsoftwares.in\/index.php\/2023\/05\/21\/explain-membership-operators-with-example\/","title":{"rendered":"Explain membership operators with example"},"content":{"rendered":"\n<p>These operators test for membership in a sequence such as lists, strings, or tuples. Two membership operators are used in Python. (in, not in). It gives the result based on the variable present in a specified sequence or string.<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<p>For example here, we check whether the value of x=4 and value of y=8 is available in list or not by using in and not in operators.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">x = 4\ny = 8\nlist = [1, 2, 3, 4, 5 ];\nif ( x in list ):\n   print(\"Line 1 - x is available in the given list\")\nelse:\n   print(\"Line 1 - x is not available in the given list\")\nif ( y not in list ):\n   print(\"Line 2 - y is not available in the given list\")\nelse:\n   print(\"Line 2 - y is available in the given list\")<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>These operators test for membership in a sequence such as lists, strings, or tuples. Two&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[20],"tags":[],"_links":{"self":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/1473"}],"collection":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/comments?post=1473"}],"version-history":[{"count":1,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/1473\/revisions"}],"predecessor-version":[{"id":1474,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/1473\/revisions\/1474"}],"wp:attachment":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/media?parent=1473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/categories?post=1473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/tags?post=1473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}