Module: (Python) Subroutines: Procedures and Functions - 1


Problem

7/11

Shorten program code

Problem

Rabbit Clover continues to learn programming. He has already studied the lines. Recently, he moved on to the study of subroutines, namely procedures. But he doesn't understand how to use them. Recently, Clover wanted to write a program that would print the longest words out of two sentences in a column (if there are several such words, then he would take the first one he encountered). He completely forgot about the procedures and wrote a very complex program.
Here she is:
s1 = input()
s2 = input()
wordMax =''
max = 0
s1 = s1 + ' '
while len(s1) > 0:
    n = s1.find(' ')
    word = s1[:n]
    if len(word) > max:
        max = len(word)
        wordMax = word
    s1 = s1[n+1:]
    
print(wordMax)

wordMax =''
max = 0
s2 = s2 + ' '
while len(s2) > 0:
    n = s2.find(' ')
    word = s2[:n]
    if len(word) > max:
        max = len(word)
        wordMax = word
    s2 = s2[n+1:]
    
print(wordMax)
Agree, this is a rather difficult program to understand. 
Help Clover the Rabbit improve the program by dividing the same actions into a subroutine.