[Tutor] calculate percents of items in a list

LN A-go-go lnartist at yahoo.com
Sun Aug 31 19:28:32 CEST 2014



What would be a better way to calculate percentages of items in a list?
please....

CountList = [9221382, 10374466, 5192905, 1710238, 3359]
CL = [float(i) for i in CountList]
CL
sum = CL[0] + CL[1] + CL[2] + CL[3] + CL[4]
import math
perList = []
n = 0
def percentage(CL,sum):
 for i in CL:
     PER = "return 100 * float (CL[0])/float (sum)"
     perList.append(PER)
     n = n + 1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140831/0b9f42d3/attachment.html>


More information about the Tutor mailing list