Question: Write a function find\_longest\_word(wordList) that takes a list of words and returns the longest word in the list. If there are multiple longest words (i.e., with the same length), then it should return the first one among them (i.e., the one that appears before others in the list).

Write a program that asks the user to enter some words separated by space (all in one line). Your program then should create a list with the words entered (you can use the built-in split method in strings for this) and output the list and the longest word (using the above function).

Sample run:

Enter a few words and I will find the longest:

The quick brown fox jumps over the lazy dog

The list of words entered is:

['The', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog']

The longest word in the list is:

quick

My code

```
    def find_longest_word():

    lizt=[]
    s = input("Please type a sentence and I will out put the longest word. ")

    for word in s:
        lizt.append(word)

    x = max(s.split(), key=len)

    print('')
    print('The list of words entered is:')
    print(lizt)
    print(s.split())
    print('')
    print('The longest word is:')
    print(x)

find_longest_word()

```

Answer: 
```
for word in s:
        lizt.append(word)

```

This loop is wrong. `s` is a string, and `word in s` will iterate through each *letter* in `s`, not each space-separated word in it. You just need to use `.split()`, your variable `lizt` is unnecessary.

You *could* do:

```
lizt = []
for word in s.split():
    lizt.append(word)

```

but this would simply result in `lizt` being the same as `s.split()`. So `lizt = s.split()` would be simpler.

And if you *really* want to use a loop for this, you could try to forgo using `max` and do the following instead:

```
max_word, max_len = None, 0
for word in s.split():
    if len(word) > max_len:
        max_word, max_len = word, len(word)

```

but it'd be simpler and more pythonic to just use `split` and `max` and not have to write an explicit loop yourself.
This code will do what you want, I think. The split method on the string, creates the word list. Then returning the max function, with the len function as the key gives you the longest word in the list. I.e. it finds the max value in the list, by applying len to each and returning the longest. 

```
s = "Please type a sentence and I will out put the longest word"
s_list = s.split()

def longest_word(s_list)

    return max(s_list, key=len) 

```