Skip to content

Commit 64ddea4

Browse files
authored
Update problem-3.py
1 parent a181429 commit 64ddea4

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

problem-3/problem-3.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
def makeGood():
2-
input_str = input("Enter a string: ")
3-
i = 0
1+
def makeGood(s):
42
result = ""
53

6-
while i < len(input_str) - 1:
7-
if abs(ord(input_str[i]) - ord(input_str[i + 1])) == 32:
8-
i += 2
4+
i = 0
5+
while i < len(s):
6+
7+
if i < len(s) - 1 and abs(ord(s[i]) - ord(s[i + 1])) == 32:
8+
9+
i += 2
910
else:
10-
result += input_str[i]
11-
i += 1
11+
12+
result += s[i]
13+
i += 1
1214

13-
if i == len(input_str) - 1:
14-
result += input_str[-1]
15-
16-
print("Result:", result)
15+
return result
1716

1817
def main():
19-
makeGood()
20-
18+
19+
input_str = "leEeetcode"
20+
output_str = makeGood(input_str)
21+
print(output_str)
2122

23+
main()

0 commit comments

Comments
 (0)