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 maximom length
max_length = 0

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

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

# Retorn the maximum length of words 
retorn max_length

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