This is the code I wrote so far. The rubric requires me to assert that the string input has alphabets, whitespaces and some special characters(!,@, etc.), but numbers are to raise an AssertionError. Is there any way to do this without isalnum() or isalpha() as either of them didn’t work.
def remove_vowels(message:str)->str:
"""
Function to identify and remove vowels from a given string
>>> remove_vowels("TL YAPA")
'TL YP'
>>> remove_vowels("remove vowels")
'rmv vwls'
>>> remove_vowels("FLY FPX FLY")
'FLY FPX FLY'
>>> remove_vowels("expecto patronum")
'xpct ptrnm'
"""
assert type(message)==str, "input must be a string"
count=len(message)
newstr=""
for i in range(0,count):
buffer=message[i]
if buffer=='a' or buffer=='e' or buffer=='i' or buffer=='o' or buffer=='u':
continue
elif buffer=='A' or buffer=='E' or buffer=='I' or buffer=='O' or buffer=='U':
continue
else:
newstr+=buffer
return newstr
New contributor
Sid Naik is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.