swapcase in python code example
Example 1: swapping in python
x = 5
y = 10
x, y = y, x
print("x =", x)
print("y =", y)
Example 2: code to swap in python
a=5
b=10
a,b=b,a
Example 3: swapcase
str_swapcase = "what was that about?".swapcase()
print(str_swapcase)
Example 4: python swap function
def swap0(s1, s2):
assert type(s1) == list and type(s2) == list
tmp = s1[:]
s1[:] = s2
s2[:] = tmp
s1, s2 = s2, s1
Example 5: non-words in python
import re
regex = re.compile('[^a-zA-Z]')
regex.sub('', 'ab3d*E')
Example 6: swapping upper case and lower case string python
string = "thE big BROWN FoX JuMPeD oVEr thE LAZY Dog"
print(string.swapcase())
>>> THe BIG brown fOx jUmpEd OveR THe lazy dOG