Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a function remove_vowels which takes one input string s, and returns a new

ID: 3596308 • Letter: W

Question

Write a function remove_vowels which takes one input string s, and returns a new string new_str, that contains string s with all the vowels removed. For example: >>>print (remove_vowels( "elephant")) phnt The above string has the vowels removed in the order e, e, a. >> print (remove_vowels( "umbrella")) mbrll The above string has the vowels removed in the order u, e, a. >> print (remove_vowels( university") nvrsty The above string has the vowels removed in the order u, i, e, i. How to do this: "aeiouAEIOU") Create a string named vowels that contain all the vowels (vowels . Create an empty string named new_str Iterate over the given string using a for loop for the range len(s) Check if each character in the string (s) is not contained in vowels If the character, s] is not in vowels, then concatenate new_str with the character . Repeat this process until you reach the end of the string Return new_str Note: You can only use len() and the membership operator in and no other string operations are permitted For example: Test Result print (remove_vowels("Elephant")) 1phnt print (remove_vowels ("Hmmm")) Hmmm

Explanation / Answer

def remove_vowels(s):
vowels="aeiouAEIOU"
new_str=""
for l in s:
if l in vowels:
continue
else:
new_str+=l
print(new_str)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote