Question: I have a trouble counting words in a list.

```
My_list = ["white is a colour", "orange is a fruit", "blue is a mood", "I like candy"]

```

What I need the script to output is the number of words in the list (15 in this case).

```
len(My_list)

```

will return "4" (the number of items).

```
for item in My_list:
    print len(item.split())

```

will give me length of each item. 

Is there a way to get the word count from a list?
Ideally, I would also like to append each word into a new list (each word is an item).

Answer: 
You can produce a list of all the individual words with:

```
words = [word for line in My_list for word in line.split()]

```

To *just* count the words, use `sum()`:

```
sum(len(line.split()) for line in My_list)

```

Demo:

```
>>> My_list = ["white is a colour", "orange is a fruit", "blue is a mood", "I like candy"]
>>> [word for line in My_list for word in line.split()]
['white', 'is', 'a', 'colour', 'orange', 'is', 'a', 'fruit', 'blue', 'is', 'a', 'mood', 'I', 'like', 'candy']
>>> sum(len(line.split()) for line in My_list)
15

```
To find the sum of the words in every item:

```
sum (len(item.split()) for item in My_list)

```

To put all the words into one list:

```
sum ([x.split() for x in My_list], [])

```