Function that calculates the percentage in a list
<p>I need to make a function that calculates the lower percentage to a value within a list. For example, there a 70.5% lower than val elements in the list. The code incomplete:</p>

<pre><code>from collections import Counter

l = [1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 4, 10]
p = [(i, Counter(l)[i] / float(len(l)) * 100.0) for i in Counter(l)]
l.sort()
newList = l[int(len(l) * .70)]

print newList, p
</code></pre>

<p>I have a 70%, but I need make this in function with value, I'm using python 2.7</p>

<p>If you need the percentage of items in a list that are less than an input, you could sort the list, get the number of items before the first occurrence of the number, divide it by the total number of items and multiply it by 100. Like so:</p>

<pre><code>list = [23, 22, 3, 4, 5, 11, 23, 2, 3, 3, 3, 3, 4]
sorted_li = sorted(li)
val = int(input())
len(sorted_li[:sorted_li.index(val)]) / float(len(sorted_li)) * 100
</code></pre>

python