Skip to content

Commit 496ab92

Browse files
URLify Done
1 parent 12cfd41 commit 496ab92

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Arrays_And_Strings/URLify.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'''
2+
URLify: Write a method to replace all spaces in a string with '%20'. You may assume that the string
3+
has sufficient space at the end to hold the additional characters, and that you are given the "true"
4+
length of the string. (Note: If implementing in Java, please use a character array so that you can
5+
perform this operation in place.)
6+
EXAMPLE
7+
Input: "Mr 3ohn Smit h 13
8+
Output: "Mr%203ohn%20Smith"
9+
Hints: #53,0118
10+
11+
'''
12+
13+
def Urlify(string):
14+
return "%20".join(tuple(string.strip().split(" ")))
15+
16+
if __name__ == '__main__':
17+
str1 = input("Enter String >> ")
18+
answer = Urlify(str1)
19+
print(answer)

0 commit comments

Comments
 (0)