Skip to content

Commit 83b461c

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 59c1457 commit 83b461c

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

strings/swapcase.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,26 @@
77
88
"""
99

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)
1213
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)
2122
else:
2223
pass
23-
swapped_list="".join(list_representation)
24+
swapped_list = "".join(list_representation)
2425
return swapped_list
2526

27+
2628
if __name__ == "__main__":
27-
# sample test
28-
input_string="Hello"
29+
# sample test
30+
input_string = "Hello"
2931
swapped_string = swap_case(input_string)
3032
print(swapped_string)
31-
32-

0 commit comments

Comments
 (0)