We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a181429 commit 64ddea4Copy full SHA for 64ddea4
problem-3/problem-3.py
@@ -1,21 +1,23 @@
1
-def makeGood():
2
- input_str = input("Enter a string: ")
3
- i = 0
+def makeGood(s):
4
result = ""
5
6
- while i < len(input_str) - 1:
7
- if abs(ord(input_str[i]) - ord(input_str[i + 1])) == 32:
8
- i += 2
+ i = 0
+ while i < len(s):
+
+ if i < len(s) - 1 and abs(ord(s[i]) - ord(s[i + 1])) == 32:
9
+ i += 2
10
else:
- result += input_str[i]
11
- i += 1
12
+ result += s[i]
13
+ i += 1
14
- if i == len(input_str) - 1:
- result += input_str[-1]
15
-
16
- print("Result:", result)
+ return result
17
18
def main():
19
- makeGood()
20
+ input_str = "leEeetcode"
+ output_str = makeGood(input_str)
21
+ print(output_str)
22
23
+main()
0 commit comments