File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments