sWAP cASE Hacker Rank Solution – Queslers

Problem: sWAP cASE Hacker Rank Solution

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".

sWAP cASE Hacker Rank Solution in Python 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)

sWAP cASE Hacker Rank Solution in Python 3

def swap_case(s):
    return s.swapcase()

sWAP cASE Hacker Rank Solution in pypy

def swap_case(s):
    res = ''
    for ch in s:
        if ch.isupper():
            res += ch.lower()
        else:
            res += ch.upper()
    return res

sWAP cASE Hacker Rank Solution in pypy3

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)
sWAP cASE Hacker Rank Solution Review:

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

Conclusion:

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

Nested Lists Hacker Rank Solution

Lists Hacker Rank Solution

Leave a Reply

Your email address will not be published. Required fields are marked *