Zaprojektuj algorytm w celu znalezienia najdłuższego słowa w ciągu znaków.
def longest_word(string): 
# Split the string into a list of words
words = string.split() 

# Initialize the maximum length
max_length = 0

# Traverse the list of words
for word in words: 
# Calcolate the length of each word
word_length = len(word)

# Keep track of the maximum length
if(word_length > max_length): 
max_length = word_length 

# Return the maximum length of words 
return max_length

# Driver's code 
input_string = 'this is a string containing words'
print(longest_word(input_string)) # Ootput: containing (Longest word of the given string)