Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
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
A single line containing a string S.
0 <= len(S) <= 1000
Print the modified string S.
Sample Input 0
HackerRank.com presents "Pythonist 2".
Sample Output 0
hACKERrANK.COM PRESENTS "pYTHONIST 2".
# Enter your code here. Read input from STDIN. Print output to STDOUT name = raw_input() print ''.join(c.lower() if c.isupper() else c.upper() for c in name)
def swap_case(s): return s.swapcase()
def swap_case(s): res = '' for ch in s: if ch.isupper(): res += ch.lower() else: res += ch.upper() return res
def swap_case(s): result = [] for letter in s: if letter == letter.lower(): result.append(letter.upper()) elif letter == letter.upper(): result.append(letter.lower()) else: result.append(letter) return ''.join(result)
In our experience, we suggest you solve this sWAP cASE Hacker Rank Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
sWAP cASE problem is available on Hacker Rank for Free, if you are stuck anywhere between a compilation, just visit Queslers to get sWAP cASE Hacker Rank Solution
I hope this sWAP cASE Hacker Rank Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Hacker Rank, Leetcode, Codechef, Codeforce Solution.
This Problem is intended for audiences of all experiences who are interested in learning Programming in a business context; there are no prerequisites.
Keep Learning!
More Hacker Rank Problem & Solutions >>
Staircase Hacker Rank Solution
A Very Big Sum Hacker Rank Solution
Diagonal Difference Hacker Rank Solution