In python , we have a
functionality by which we can swap the cases from upper to lower and
vice versa. This can be achieved by the function called swapcase .
Example
:- The input that will be
provided here will get converted into
the alternative case
data = input()
print(data.swapcase())
We can convert the case with
writing a function also.
Example
:-
def swap_case(s):
result1=""
for i in s:
if i.isupper():
newletter= i.lower()
result1 +=
''.join(newletter)
else:
newletter=i.upper()
result1
+=''.join(newletter)
return result1
if __name__ == '__main__':
s = input()
result = swap_case(s)
print(result)
No comments:
Post a Comment