Skip to content

Commit 93f12f4

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent dc2411f commit 93f12f4

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

strings/swap-case.py

+15-14
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
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
33
# eg: input: s= "Hello" output: t="hELLO"
4-
m=list(s)
4+
m = list(s)
55
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)
1414
else:
1515
pass
16-
t=[ele for ele in m]
17-
t="".join(t)
16+
t = [ele for ele in m]
17+
t = "".join(t)
1818
return t
1919

20-
s=input()
21-
sc= swap_case(s)
20+
21+
s = input()
22+
sc = swap_case(s)
2223
print(sc)

0 commit comments

Comments
 (0)