Python Swapcase String Method

Publié le: 06 octobre 2015
sur la chaîne: Code master
3,040
22

Be sure to like, share and comment to show your support for our tutorials.

=======================================
Channel - https://goo.gl/pnKLqE
Playlist For This Tutorial - https://goo.gl/EyZFti
Latest Video - https://goo.gl/atWRkF
Facebook -   / mastercodeonline  
Twitter - https://twitter.com/mastercodeonlin?l...
Website - http://mastercode.online
======================================

Python Swapcase String Method
In this Python tutorial, we look at the Python swapcase string method which allows us to be able to switch uppercase characters to lowercase and lowercase to uppercase. The swapcase string method is very straight forward if you have a lowercase character it will be converted to uppercase and uppercase will be converted to lowercase. There are no arguments for this string method.

Python Swapcase String Method Syntax
'String Object'.swapcase()

'String Object' - This is our string object that we are going to call swapcase string method on.
.swapcase() - Swapcase string method will switch the case of a character. There is no arguments for the swapcase string method.
Examples Of The Swapcase String Method
#Example 1
'this is a string'.swapcase()
'THIS IS A STRING'

#Example 2
'THIS IS ANOTHER STRING IN UPPERCASE'.swapcase()
'this is another string in uppercase'
Examples Explained

Example 1:

'this is a string'.swapcase() - We create a new string object and call the swapcase string method on the string method.

'THIS IS A STRING' - We are returned a new string object that contains all uppercase characters.

Example 2:

'THIS IS ANOTHER STRING IN UPPERCASE'.swapcase() - We create a new string object and we then call the swapcase string method on our object.

'this is another string in uppercase' - We are returned a new string object that contains all lowercase characters.

Conclusion

In this Python tutorial we took a look at the swapcase string method which allows us to change the case of a string object. If you have any questions about the swapcase string method leave a comment below.


Sur cette page du site, vous pouvez voir la vidéo en ligne Python Swapcase String Method durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Code master 06 octobre 2015, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 3,040 fois et il a aimé 22 téléspectateurs. Bon visionnage!