Question: I have been working on my code in Python, but cant seem to figure out where the error is. If anyone can assist, or provide a hint to push me in the right direction, it would be greatly appreciated.

```
def find_longest_word(a):

    length = len(a[0])
    word = a[0]
    for i in wordlist:
      if len(i) > length:
          word = (i)
          length = len(i)

    return word, length

def main():

    wordlist = input("Enter a few words and I will find the longest: ").split()
    word, length = find_longest_word(wordlist)
    print (word,"is the longest word that you have listed.")

main()

```

Answer: 
1. Indentation is missing.
2. In the `find_longest_word` function `wordlist` is not define. We need to use variable `a` in the `for` loop. Change from `for i in wordlist:` to `for i in a:`
3. I am using python 2.7, So `raw_input()` is used.

code:

```
def find_longest_word(a):

    length = len(a[0])
    word = a[0]
    for i in a:
        if len(i) > length:
            word = i
            length = len(i)

    return word, length

def main():

    wordlist = raw_input("Enter a few words and I will find the longest: ").split()
    word, length = find_longest_word(wordlist)
    print (word,"is the longest word that you have listed.")

main()

```

output:

```
vivek@vivek:~/Desktop/stackoverflow$ python 23.py 
Enter a few words and I will find the longest: 1 234 2344 3 4
('2344', 'is the longest word that you have listed.')

```

---

By using collections module and dictionary methods.

```
>>> import collections
>>> msg = "whish word is longest from this msg"
>>> msg.split()
['whish', 'word', 'is', 'longest', 'from', 'this', 'msg']
>>> d = collections.defaultdict(list)
>>> for i in msg.split():
...    d[len(i)].append(i)
... 
>>> d
defaultdict(<type 'list'>, {2: ['is'], 3: ['msg'], 4: ['word', 'from', 'this'], 5: ['whish'], 7: ['longest']})
>>> max(d.keys())
7
>>> d[max(d.keys())]
['longest']
>>> 

```
Python is **indentation sensitive**!
Python expects a **code block** after `:`. End of definition is determined by a lesser indentation than the current one. 

Unlike C family Python doesn't have `{}` to determine where a block starts or ends.

Your code should look like this:

```
def find_longest_word(a):
    length = len(a[0])
    word = a[0]
    for i in wordlist:
         if len(i) > length:
              word = (i)
              length = len(i)

    return word, length

def main(): #EXPECTS INDENTATION
    #CODE INSIDE THE INDENTED CODE BLOCK WILL BE EXECUTED
    #ONLY IF FUNCTION main() IS CALLED
    wordlist = input("Enter a few words and I will find the longest: ").split()
    word, length = find_longest_word(wordlist)
    print (word,"is the longest word that you have listed.")

#END OF INDENTATION MARKS THE END OF A CODE BLOCK 
#THIS MEANS main() WILL GET CALLED EVERYTIME YOU 
#START THIS PROGRAM IN IDLE
main()

```

apart from that there's also some logical errors in your code that will also cause an error.