sWAP cASE in Python - HackerRank Solution

sWAP cASE - Python HackerRank Solution

Hello Friends, How are you? Today I am going to solve the HackerRank sWAP cASE Problem in Python with a very easy explanation. In this article, you will get one or more approaches to solving this problem. So let's start-

{tocify} $title={Table of Contents}

Default Arguments Python HackerRank Solution

HackerRank Python sWAP cASE Solution - Problem Statement

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 {codeBox}

Function Description

Complete the swap_case function in the editor below.

swap_case has the following parameters:
  • string s: the string to modify

  • string: the modified string

Input Format

A single line containing a string s.


0 < len(S) <= 1000

Sample Input 0

HackerRank.com presents "Pythonist 2". {codeBox}

Sample Output 0


Python sWAP cASE - Hacker Rank Solution

Approach I: sWAP cASE HackerRank Python Solution

# ========================
#       Information
# ========================

# Name: sWAP cASE in Python HackerRank
# Direct Link: https://www.hackerrank.com/challenges/swap-case/problem
# Difficulty: Easy
# Max Score: 10
# Language: Pypy 3

# ========================
#         Solution Start
# ========================

#sWAP cASE in Python - Hacker Rank Solution
def swap_case(s):
    num = ""
    for let in s:
        if let.isupper() == True:
    return num

if __name__ == '__main__':
    s = input()
    result = swap_case(s)
#sWAP cASE in Python - Hacker Rank Solution END
# MyEduWaves

Disclaimer: The above Problem ( Python sWAP cASE ) is generated by Hackerrank but the Solution is Provided by MyEduWaves. This tutorial is only for Educational and Learning purposes. Authority if any queries regarding this post or website fill out the contact form.

I hope you have understood the solution to this HackerRank Problem. All these three solutions will pass all the test cases. Now visit Python sWAP cASE Hackerrank Problem and try to solve it again.

All the Best!

Post a Comment

Previous Post Next Post