File tree 1 file changed +15
-15
lines changed
1 file changed +15
-15
lines changed Original file line number Diff line number Diff line change 7
7
8
8
"""
9
9
10
- def swap_case (input_string :str ):
11
- list_representation = list (input_string )
10
+
11
+ def swap_case (input_string : str ):
12
+ list_representation = list (input_string )
12
13
for i in range (len (list_representation )):
13
- if list_representation [i ]>= "A" and list_representation [i ]<= "Z" :
14
- m2 = ord (list_representation [i ])
15
- m1 = m2 + 32
16
- list_representation [i ]= chr (m1 )
17
- elif list_representation [i ]>= "a" and list_representation [i ]<= "z" :
18
- m3 = ord (list_representation [i ])
19
- m4 = m3 - 32
20
- list_representation [i ]= chr (m4 )
14
+ if list_representation [i ] >= "A" and list_representation [i ] <= "Z" :
15
+ m2 = ord (list_representation [i ])
16
+ m1 = m2 + 32
17
+ list_representation [i ] = chr (m1 )
18
+ elif list_representation [i ] >= "a" and list_representation [i ] <= "z" :
19
+ m3 = ord (list_representation [i ])
20
+ m4 = m3 - 32
21
+ list_representation [i ] = chr (m4 )
21
22
else :
22
23
pass
23
- swapped_list = "" .join (list_representation )
24
+ swapped_list = "" .join (list_representation )
24
25
return swapped_list
25
26
27
+
26
28
if __name__ == "__main__" :
27
- # sample test
28
- input_string = "Hello"
29
+ # sample test
30
+ input_string = "Hello"
29
31
swapped_string = swap_case (input_string )
30
32
print (swapped_string )
31
-
32
-
You can’t perform that action at this time.
0 commit comments