class Database(Student):
def __init__(self):
g = []
choice = ['Basketball','Football','Other','Baseball','Handball','Soccer','Volleyball','I do not like sport']
data = student.sport
k = len(student.fname)
print k
freq = {}
for i in data:
freq[i] = freq.get(i, 0) + 1
for i in choice:
if i not in freq:
freq[i] = 0
for i in freq:
print i, freq[i]
I want to calculate each frequency in percentage. I tried to use freq / k but all returned 0 0 0 0 0 0
How do I calculate each frequency?