Skip to content

Commit 6cfacc6

Browse files
Toogle_String_Program is updated
Question is to convert upper case characters to lower case and vice-versa.
1 parent 588f604 commit 6cfacc6

2 files changed

Lines changed: 30 additions & 19 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""
2+
Question
3+
You have been given a String S consisting of uppercase and lowercase English alphabets. You need to change the case of each alphabet
4+
in this String. That is, all the uppercase letters should be converted to lowercase and all the lowercase letters should be converted
5+
to uppercase. You need to then print the resultant String to output.
6+
Source Hackerearth
7+
8+
SAMPLE INPUT
9+
abcdE
10+
SAMPLE OUTPUT
11+
ABCDe
12+
"""
13+
14+
def ToggleString1(string):
15+
return string.swapcase()
16+
17+
def ToggleString2(string):
18+
toggleString=''
19+
for s in string:
20+
if s.isupper():
21+
toggleString+=s.lower()
22+
elif s.islower():
23+
toggleString+=s.upper()
24+
return toggleString
25+
26+
27+
28+
string=input()
29+
print(ToggleString1(string)) # method 1
30+
print(ToggleString2(string)) # method 2

data_structures/strings/Palindromic_String.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)