Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for First Word (simplified) by Seniakuzin
def first_word(text: str) -> str:
for i in range(len(text)):
if text[i] == " ":
return(text[0:i])
return text
if __name__ == "__main__":
print("Example:")
print(first_word("Hello world"))
assert first_word("Hello world") == "Hello"
assert first_word("a word") == "a"
assert first_word("hi") == "hi"
July 8, 2020
Comments: