Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 135438e

Browse files
author
Amogh Singhal
authored
Create remove_chars.py
1 parent e9aa07c commit 135438e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

‎remove_chars.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Write an efficient function that deletes characters from an ASCII
2+
# string where any character existing in remove must be deleted from
3+
# str. For example, given a str of "Battle of the Vowels: Hawaii vs.
4+
# Grozny" and a remove of "aeiou", the function should transform str
5+
# to "Bttl f th Vwls: Hw vs. Grzny".
6+
7+
def removeChars(main_string, remove_string):
8+
result = ''
9+
for char in main_string:
10+
if char not in remove_string:
11+
result+=char
12+
return result
13+
14+
given_input = "Battle of the Vowels: Hawaii vs. Grozny"
15+
vowels = "aeiou"
16+
print(removeChars(given_input, vowels))

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /