swap in python 1

swap in python

Python swapcase() method Example
text1 = "pYTHON tUTORIALS"
print(text1.swapcase())

text2 = "HELLO WORLD"
print(text2.swapcase())

text3 = "welcome to itsmycode"
print(text3.swapcase())

text4 ="12345!!!"
print(text4.swapcase())

Here is what the above code is Doing:
1. We created a string variable text1 and assigned a string to it.
2. We used the swapcase() method on the string variable text1.
3. The swapcase() method returns a string where all the upper case letters are converted to lower case and all the lower case letters are converted to upper case.
4. We printed the output of the swapcase() method.
5. We created a string variable text2 and assigned a string to it.
6. We used the swapcase() method on the string variable text2.
7. The swapcase() method returns a string where all the upper case letters are converted to lower case and all the lower case letters are converted to upper case.
8. We printed the output of the swapcase() method.
9. We created a string variable text3 and assigned a string to it.
10. We used the swapcase() method on the string variable text3.
11. The swapcase() method returns a string where all the upper case letters are converted to lower case and all the lower case letters are converted to upper case.
12. We printed the output of the swapcase() method.
13. We created a string variable text4 and assigned a string to it.
14. We used the swapcase() method on the string variable text4.
15. The swapcase() method returns a string where all the upper case letters are converted to lower case and all the lower case letters are converted to upper case.
16. We printed the output of the swapcase() method.

Similar Posts