File tree 1 file changed +15
-14
lines changed
1 file changed +15
-14
lines changed Original file line number Diff line number Diff line change 1
1
def swap_case (s ):
2
- #This method will swap the cases of a given string
2
+ # This method will swap the cases of a given string
3
3
# eg: input: s= "Hello" output: t="hELLO"
4
- m = list (s )
4
+ m = list (s )
5
5
for i in range (len (m )):
6
- if m [i ]>= 'A' and m [i ]<= 'Z' :
7
- m2 = ord (m [i ])
8
- m1 = m2 + 32
9
- m [i ]= chr (m1 )
10
- elif m [i ]>= 'a' and m [i ]<= 'z' :
11
- m3 = ord (m [i ])
12
- m4 = m3 - 32
13
- m [i ]= chr (m4 )
6
+ if m [i ] >= "A" and m [i ] <= "Z" :
7
+ m2 = ord (m [i ])
8
+ m1 = m2 + 32
9
+ m [i ] = chr (m1 )
10
+ elif m [i ] >= "a" and m [i ] <= "z" :
11
+ m3 = ord (m [i ])
12
+ m4 = m3 - 32
13
+ m [i ] = chr (m4 )
14
14
else :
15
15
pass
16
- t = [ele for ele in m ]
17
- t = "" .join (t )
16
+ t = [ele for ele in m ]
17
+ t = "" .join (t )
18
18
return t
19
19
20
- s = input ()
21
- sc = swap_case (s )
20
+
21
+ s = input ()
22
+ sc = swap_case (s )
22
23
print (sc )
You can’t perform that action at this time.
0 commit comments