Hello coders, today we will be solving sWAP cASE Hacker Rank Solution in Python.
Problem
You are given a string and your task is to swap cases. In other words, convert all lowercase letters to uppercase letters and vice versa.
For Example:
Www.HackerRank.com → wWW.hACKERrANK.COM Pythonist 2 → pYTHONIST 2
Input Format
A single line containing a string S.
Constraints
0 <= len(S) <= 1000
Output Format
Print the modified string S.
Sample Input 0
HackerRank.com presents "Pythonist 2".
Sample Output 0
hACKERrANK.COM PRESENTS "pYTHONIST 2".
Solution - sWAP cASE in Python - Hacker Rank Solution
def swap_case(s): num = "" for let in s: if let.isupper() == True: num+=(let.lower()) else: num+=(let.upper()) return num if __name__ == '__main__': s = input() result = swap_case(s) print(result)
Disclaimer: The above Problem (sWAP cAse) is generated by Hacker Rank but the Solution is provided by Sloth Coders.
Happy Coding !!
A Sloth Who loves to Code
Also Read: