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 Khrystyna11
def first_word(text: str) -> str:
result = ""
i = 0
while i < len(text):
if text[i] == " ":
break
result += text[i]
i += 1
return result
print("Example:")
print(first_word("Hello world"))
# These "asserts" are used for self-checking
assert first_word("Hello world") == "Hello"
assert first_word("a word") == "a"
assert first_word("greeting from CheckiO Planet") == "greeting"
assert first_word("hi") == "hi"
print("The mission is done! Click 'Check Solution' to earn rewards!")
June 3, 2024
Comments: