Question: i am learning php as well as doing a project that involves uploading files to the server. My goal is to make it as secure as possible so where do you recommend saving all the uploaded files. The files to be uploaded will all be pdf files. I read somewhere it's better to save uploaded files outside document root and in some other place i read it's not easy to access files outside document root from php so i am very confused. Any help towards best practice to overcome this situation is appreciated! Thanks!

Answer: 
A list of the lengths of each element in a list:

```
lengths = [len(i) for i in my_list]

```

For the average:

```
def averageLen(lst):
    lengths = [len(i) for i in lst]
    return 0 if len(lengths) == 0 else (float(sum(lengths)) / len(lengths)) 

```

If it's a list of lists:

```
lengths = [averageLen(i) for i in my_list]

```
First, iterating over a list in python only copies the value of each item into a temporary variable. So in fact, in your example, `k` is assigned a value of each item in the list, but changing it doesn't change the original list.
Second, it seems that you tried to map each item in the list to its length, and not to the average length of its items. Mapping each item to its length could be easily done with the builtin function `map`: `map(len,lengths)`.
However, to accomplish what you request, we're gonna need to improve a little bit. Let's define a function to calculate the average length of a lists items:

```
def average_len(l):
  return sum(map(len, l))/float(len(l))

```

Now we can use map again to get the average of each sublist: `map(average_len, lengths)`.