Light Mode
Dark Mode
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"))

Created: Jan. 25, 2023, 3:43 p.m.
Updated: Jan. 26, 2023, 6:34 a.m.
0
5
User avatar
Skeen04