Why it's wrong?
Your result:'Holy ' assert first_word('Holy Edison') == 'Holy'
it's my code:
import re
def firstword(text: str) -> str:
if "," in text:
text = text.replace(",", "")
if "." in text:
text = text.replace(".", "")
mylist = re.findall('[a-zA-Z][^A-Z]*', text)
if len(mylist) > 1:
return mylist[0]
else:
text = text.split()
return text[0]
print(firstword("Hello world")) print(firstword(" a word ")) print(firstword("don't touch it")) print(firstword("greetings, friends"))