Skip to content

Commit b7d9935

Browse files
Update swapcase.py
1 parent b8ad822 commit b7d9935

File tree

1 file changed

+0
-21
lines changed

1 file changed

+0
-21
lines changed

strings/swapcase.py

-21
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,6 @@ def swap_case(input_string: str) -> str:
2727
swapped_list = "".join(list_representation)
2828
return swapped_list
2929

30-
31-
def swap_case(input_string) -> None:
32-
# This method will swap the cases of a given string
33-
# eg: input: s= "Hello" output: t="hELLO"
34-
list_representation = list(input_string)
35-
for i in range(len(list_representation)):
36-
if list_representation[i] >= "A" and list_representation[i] <= "Z":
37-
m2 = ord(list_representation[i])
38-
m1 = m2 + 32
39-
list_representation[i] = chr(m1)
40-
elif list_representation[i] >= "a" and list_representation[i] <= "z":
41-
m3 = ord(list_representation[i])
42-
m4 = m3 - 32
43-
list_representation[i] = chr(m4)
44-
else:
45-
pass
46-
swapped_list = [ele for ele in list_representation]
47-
swapped_list = "".join(swapped_list)
48-
return swapped_list
49-
50-
5130
if __name__ == "__main__":
5231
# sample test case
5332
input_string = "Hello"

0 commit comments

Comments
 (0)