Python SWAP CASE HackerRank Solution
Task
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.
Example
Www.HackerRank.com → wWW.hACKERrANK.COM
Sample Input 0
HackerRank.com presents "Pythonist 2".
Sample Output 0
hACKERrANK.COM PRESENTS "pYTHONIST 2".
def swap_case(s): string=" " for ch in s: if(ch.islower()): string=string+ch.upper() else: string=string+ch.lower() return string.strip()
if __name__ == '__main__': s = input() result = swap_case(s) print(result)
Python SWAP CASE HackerRank Solution
Reviewed by Shubham Prajapati
on
August 18, 2023
Rating:
No comments:
If you have any doubt so you can comment me then i will 100% help you ,Through comment Chat