Code:
def show_word(word: str) -> None:
    print(f"Mot: '{word}'")


my_string = "This is fun!"

last_space_position: int = -1
next_space: int = my_string.find(" ")

while next_space != -1:
    word: str = my_string[last_space_position + 1 : next_space]
    show_word(word)
    last_space_position = next_space
    next_space = my_string.find(" ", last_space_position + 1)

last_word: str = my_string[last_space_position + 1 :]
show_word(last_word)
Last modified: Friday, 1 March 2024, 16:17