{"id":18800,"date":"2020-09-17T04:13:31","date_gmt":"2020-09-17T04:13:31","guid":{"rendered":"http:\/\/www.devopsschool.com\/blog\/?p=18800"},"modified":"2022-07-24T10:11:21","modified_gmt":"2022-07-24T10:11:21","slug":"membership-operators-in-python","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/membership-operators-in-python\/","title":{"rendered":"Python Tutorials: Membership Operators in Python"},"content":{"rendered":"\n<p>The membership operators are useful to test for membership in a sequence such as string, lists, tuples and dictionaries.<\/p>\n\n\n\n<p>There are two type of Membership operator:-<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>in<\/li><li>not in<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>1.in<\/strong><\/h2>\n\n\n\n<p>This operators is used to find an element in the specified sequence.<\/p>\n\n\n\n<p>It returns True if element is found in the specified sequence else it returns False.<\/p>\n\n\n\n<p><strong>Examples:-<\/strong><\/p>\n\n\n\n<p>st1 = \u201cWelcome to devopsschool\u201d<\/p>\n\n\n\n<p>\u201cto\u201d in st1  <strong>True<\/strong><\/p>\n\n\n\n<p>st2 = \u201cWelcome top devopsschool\u201d<\/p>\n\n\n\n<p>\u201cto\u201d in st2  <strong>True<\/strong><\/p>\n\n\n\n<p>st3 = \u201cWelcome to devopsschool\u201d <\/p>\n\n\n\n<p>\u201csubs\u201d in st3  <strong>False<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2.<strong>not in<\/strong><\/h2>\n\n\n\n<p>This operators works in reverse manner for in operator.<\/p>\n\n\n\n<p>It returns True if element is not found in the specified sequence and if element is found, then it returns False.<\/p>\n\n\n\n<p><strong>Examples:-<\/strong><\/p>\n\n\n\n<p>st1 = \u201cWelcome to devopsschool\u201d<\/p>\n\n\n\n<p>\u201csubs\u201d not in st1  <strong>True<\/strong><\/p>\n\n\n\n<p>st2 = \u201cWelcome to devopsschool\u201d<\/p>\n\n\n\n<p>\u201cto\u201d not in st2   <strong>False<\/strong><\/p>\n\n\n\n<p>st3 = \u201cWelcome top devopsschool\u201d<\/p>\n\n\n\n<p> \u201cto\u201d not in st3 <strong>False<\/strong><\/p>\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_61771\"><iframe loading=\"lazy\"  id=\"_ytid_97993\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_61771\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>The membership operators are useful to test for membership in a sequence such as string, lists, tuples and dictionaries. There are two type of Membership operator:- in not in 1.in&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[499],"tags":[],"class_list":["post-18800","post","type-post","status-publish","format-standard","hentry","category-python-programming-scripting-languages"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/18800","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=18800"}],"version-history":[{"count":4,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/18800\/revisions"}],"predecessor-version":[{"id":30720,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/18800\/revisions\/30720"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=18800"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=18800"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=18800"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}