File tree 1 file changed +14
-13
lines changed
1 file changed +14
-13
lines changed Original file line number Diff line number Diff line change 12
12
def swap_case (input_string ) -> str :
13
13
"""This method will swap the cases of a given string
14
14
eg: input: input_string= "Hello" output: swapped_string="hELLO" """
15
- list_representation = list (input_string )
15
+ list_representation = list (input_string )
16
16
for i in range (len (list_representation )):
17
- if list_representation [i ]>= 'A' and list_representation [i ]<= 'Z' :
18
- m2 = ord (list_representation [i ])
19
- m1 = m2 + 32
20
- list_representation [i ]= chr (m1 )
21
- elif list_representation [i ]>= 'a' and list_representation [i ]<= 'z' :
22
- m3 = ord (list_representation [i ])
23
- m4 = m3 - 32
24
- list_representation [i ]= chr (m4 )
17
+ if list_representation [i ] >= "A" and list_representation [i ] <= "Z" :
18
+ m2 = ord (list_representation [i ])
19
+ m1 = m2 + 32
20
+ list_representation [i ] = chr (m1 )
21
+ elif list_representation [i ] >= "a" and list_representation [i ] <= "z" :
22
+ m3 = ord (list_representation [i ])
23
+ m4 = m3 - 32
24
+ list_representation [i ] = chr (m4 )
25
25
else :
26
26
pass
27
- swapped_list = [ele for ele in list_representation ]
28
- swapped_list = "" .join (swapped_list )
27
+ swapped_list = [ele for ele in list_representation ]
28
+ swapped_list = "" .join (swapped_list )
29
29
return swapped_list
30
30
31
- input_string = input ()
32
- swapped_string = swap_case (input_string )
31
+
32
+ input_string = input ()
33
+ swapped_string = swap_case (input_string )
33
34
print (swapped_string )
You can’t perform that action at this time.
0 commit comments