{"id":4729,"date":"2022-08-16T12:18:21","date_gmt":"2022-08-16T12:18:21","guid":{"rendered":"https:\/\/www.wikitechy.com\/interview-questions\/?p=4729"},"modified":"2022-08-16T12:18:21","modified_gmt":"2022-08-16T12:18:21","slug":"what-is-swapcase-function-in-the-python","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-swapcase-function-in-the-python\/","title":{"rendered":"What is swapcase () function in the Python ?"},"content":{"rendered":"<ul>\n<li style=\"text-align: justify;\">In python it is a string\u2019s function which converts all uppercase characters into lowercase and vice versa.<\/li>\n<li style=\"text-align: justify;\">This function is used to alter the existing case of the string.<\/li>\n<li style=\"text-align: justify;\">In swapcase this method creates a copy of the string which contains all the characters.<\/li>\n<li style=\"text-align: justify;\">It generates a small case string and vice versa, if the string is in lowercase and automatically ignores all the non-alphabetic characters.<\/li>\n<li style=\"text-align: justify;\">The swapcase function does not takes any parameter.<\/li>\n<li style=\"text-align: justify;\">With all the cases changed the swapcase () method returns a string.<\/li>\n<\/ul>\n<h3 id=\"sample-code\" style=\"text-align: justify;\">Sample Code<\/h3>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-python code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-python code-embed-code\"># Python program to demonstrate the use of<br\/># swapcase() method  <br\/>  <br\/>string = &quot;Welcome to Wikitechy&quot;<br\/>  <br\/># prints after swappong all cases<br\/>print(string.swapcase())   <br\/>  <br\/>string = &quot;striver&quot; <br\/>print(string.swapcase())  <\/code><\/pre> <\/div>\n<h3 id=\"output\" style=\"text-align: justify;\">Output<\/h3>\n<p style=\"text-align: justify;\"><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-full wp-image-4730\" src=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/swapcase-method.png\" alt=\"\" width=\"1243\" height=\"274\" srcset=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/swapcase-method.png 1243w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/swapcase-method-300x66.png 300w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/swapcase-method-1024x226.png 1024w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/swapcase-method-768x169.png 768w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/swapcase-method-390x86.png 390w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/swapcase-method-820x181.png 820w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/swapcase-method-1180x260.png 1180w\" sizes=\"(max-width: 1243px) 100vw, 1243px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In python it is a string\u2019s function which converts all uppercase characters into lowercase and vice versa. This function is used to alter the existing case of the string. In swapcase this method creates a copy of the string which contains all the characters. It generates a small case string and vice versa, if the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5608],"tags":[18261,18260,18257,18259,18258,18264,18266,18267,18268,18265,18263,18262],"class_list":["post-4729","post","type-post","status-publish","format-standard","hentry","category-python","tag-convert-all-lowercase-letters-to-uppercase-letters-and-vice-versa-in-python","tag-how-to-swap-case-of-string-in-python","tag-how-to-swapcase-in-python-without-inbuilt-function","tag-swap-case-in-python","tag-swap-case-python-using-function","tag-swapcase-function-in-python-3","tag-swapcase-method-in-python","tag-what-are-in-python","tag-what-does-any-do-in-python","tag-what-is-in-python-function","tag-what-is-swapcase-in-python","tag-what-is-swapcase-function-in-the-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>What is swapcase () function in the Python ? - Swapcase in Python<\/title>\n<meta name=\"description\" content=\"What is swapcase () function in the Python ? - In python it is a string&#039;s function which converts all uppercase characters into lowercase 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.wikitechy.com\/interview-questions\/python\/what-is-swapcase-function-in-the-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is swapcase () function in the Python ? - Swapcase in Python\" \/>\n<meta property=\"og:description\" content=\"What is swapcase () function in the Python ? - In python it is a string&#039;s function which converts all uppercase characters into lowercase and vice versa.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-swapcase-function-in-the-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Wikitechy\" \/>\n<meta property=\"article:published_time\" content=\"2022-08-16T12:18:21+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/swapcase-method.png\" \/>\n<meta name=\"author\" content=\"webmaster\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"webmaster\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/python\\\/what-is-swapcase-function-in-the-python\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/python\\\/what-is-swapcase-function-in-the-python\\\/\"},\"author\":{\"name\":\"webmaster\",\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/#\\\/schema\\\/person\\\/f785ba3ecc599133e65ab6138042a3e4\"},\"headline\":\"What is swapcase () function in the Python ?\",\"datePublished\":\"2022-08-16T12:18:21+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/python\\\/what-is-swapcase-function-in-the-python\\\/\"},\"wordCount\":140,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/python\\\/what-is-swapcase-function-in-the-python\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/swapcase-method.png\",\"keywords\":[\"convert all lowercase letters to uppercase letters and vice versa in python\",\"how to swap case of string in python\",\"how to swapcase in python without inbuilt function\",\"swap case in python\",\"swap case python using function\",\"swapcase function in python 3\",\"swapcase method in python\",\"what are () in python\",\"what does any() do in python\",\"what is * in python function\",\"what is swapcase in python\",\"what is swapcase() function in the python\"],\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/python\\\/what-is-swapcase-function-in-the-python\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/python\\\/what-is-swapcase-function-in-the-python\\\/\",\"url\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/python\\\/what-is-swapcase-function-in-the-python\\\/\",\"name\":\"What is swapcase () function in the Python ? - Swapcase in Python\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/python\\\/what-is-swapcase-function-in-the-python\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/python\\\/what-is-swapcase-function-in-the-python\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/swapcase-method.png\",\"datePublished\":\"2022-08-16T12:18:21+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/#\\\/schema\\\/person\\\/f785ba3ecc599133e65ab6138042a3e4\"},\"description\":\"What is swapcase () function in the Python ? - In python it is a string's function which converts all uppercase characters into lowercase and vice versa.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/python\\\/what-is-swapcase-function-in-the-python\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/python\\\/what-is-swapcase-function-in-the-python\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/swapcase-method.png\",\"contentUrl\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/swapcase-method.png\",\"width\":1243,\"height\":274},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/#website\",\"url\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/\",\"name\":\"Wikitechy\",\"description\":\"Interview Questions\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/#\\\/schema\\\/person\\\/f785ba3ecc599133e65ab6138042a3e4\",\"name\":\"webmaster\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"caption\":\"webmaster\"},\"sameAs\":[\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\"],\"url\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/author\\\/webmaster\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is swapcase () function in the Python ? - Swapcase in Python","description":"What is swapcase () function in the Python ? - In python it is a string's function which converts all uppercase characters into lowercase 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.wikitechy.com\/interview-questions\/python\/what-is-swapcase-function-in-the-python\/","og_locale":"en_US","og_type":"article","og_title":"What is swapcase () function in the Python ? - Swapcase in Python","og_description":"What is swapcase () function in the Python ? - In python it is a string's function which converts all uppercase characters into lowercase and vice versa.","og_url":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-swapcase-function-in-the-python\/","og_site_name":"Wikitechy","article_published_time":"2022-08-16T12:18:21+00:00","og_image":[{"url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/swapcase-method.png","type":"","width":"","height":""}],"author":"webmaster","twitter_card":"summary_large_image","twitter_misc":{"Written by":"webmaster","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-swapcase-function-in-the-python\/#article","isPartOf":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-swapcase-function-in-the-python\/"},"author":{"name":"webmaster","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4"},"headline":"What is swapcase () function in the Python ?","datePublished":"2022-08-16T12:18:21+00:00","mainEntityOfPage":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-swapcase-function-in-the-python\/"},"wordCount":140,"commentCount":0,"image":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-swapcase-function-in-the-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/swapcase-method.png","keywords":["convert all lowercase letters to uppercase letters and vice versa in python","how to swap case of string in python","how to swapcase in python without inbuilt function","swap case in python","swap case python using function","swapcase function in python 3","swapcase method in python","what are () in python","what does any() do in python","what is * in python function","what is swapcase in python","what is swapcase() function in the python"],"articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-swapcase-function-in-the-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-swapcase-function-in-the-python\/","url":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-swapcase-function-in-the-python\/","name":"What is swapcase () function in the Python ? - Swapcase in Python","isPartOf":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-swapcase-function-in-the-python\/#primaryimage"},"image":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-swapcase-function-in-the-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/swapcase-method.png","datePublished":"2022-08-16T12:18:21+00:00","author":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4"},"description":"What is swapcase () function in the Python ? - In python it is a string's function which converts all uppercase characters into lowercase and vice versa.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-swapcase-function-in-the-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-swapcase-function-in-the-python\/#primaryimage","url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/swapcase-method.png","contentUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/swapcase-method.png","width":1243,"height":274},{"@type":"WebSite","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website","url":"https:\/\/www.wikitechy.com\/interview-questions\/","name":"Wikitechy","description":"Interview Questions","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4","name":"webmaster","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","caption":"webmaster"},"sameAs":["https:\/\/www.wikitechy.com\/interview-questions"],"url":"https:\/\/www.wikitechy.com\/interview-questions\/author\/webmaster\/"}]}},"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4729","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/comments?post=4729"}],"version-history":[{"count":1,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4729\/revisions"}],"predecessor-version":[{"id":4731,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4729\/revisions\/4731"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/media?parent=4729"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/categories?post=4729"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/tags?post=4729"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}