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 3b60935 commit 54b4d6dCopy full SHA for 54b4d6d
Python/chapter01/1.3 - URLify/miguel_1.3_sol.py
@@ -19,15 +19,17 @@ def urlify(s: str, true_length: int) -> str:
19
:param true_length: since s may have additional characters, we focus on true_length instead of actual s length
20
:return: string with each space from s replaced with '%20'
21
"""
22
- output = ""
+ # Below link goes over string concat efficiency in python (I will use method 4
23
+ # https://waymoot.org/home/python_string/
24
+ output = []
25
for i, c in enumerate(s):
26
if i == true_length:
27
break
28
if c == ' ':
- output += "%20"
29
+ output.append("%20")
30
continue
- output += c
- return output
31
+ output.append(c)
32
+ return ''.join(output)
33
34
35
class TestUrlifyFunction(unittest.TestCase):
0 commit comments