import sys

sys.argv([0])

sentence = str(sys.argv([1])

def longest_word(sentence):
longest_word = max(sentence, key=len)
return longest_word

print("Longest word is: ", sentence)

I keep getting an error where it states
def longest_word(sentence):
^
SyntaxError: invalid syntax
Please help me where I went wrong.

Respuesta :

The error in your code is that you are missing the : at the end of the if statement

The corrected code:

def find_longest_word(word_list):  

   longest_word = ''  

   longest_size = 0  

   for word in word_list:    

       if (len(word) > longest_size):

           longest_word = word

           longest_size = len(word)      

   return longest_word

words = input('Please enter a few words')  

word_list = words.split()  

find_longest_word(word_list)

Read more about python programming  here:

https://brainly.com/question/26497128

#SPJ1

ACCESS MORE
ACCESS MORE
ACCESS MORE
ACCESS MORE