I have the following list of list:
website=[["Ram"],["google"],["yahoo"],["linkedin"],["facebook"],["twitter"],
["google"],["yahoo"],["linkedin"],["facebook"],["twitter"],["google"],["yahoo"],
["linkedin"]]
i would like to get the output like:
webdict={"Ram":1,"google":3,"yahoo":3,"linkedin":3,"facebook":2,"twitter":2}
website=[["Ram"],["google"],["yahoo"],["linkedin"],["facebook"],["twitter"],["google"],["yahoo"],["linkedin"],["facebook"],["twitter"],["google"],["yahoo"],["linkedin"]]
print dict([(i[0], website.count(i)) for i in website])
The output :
{'google': 3, 'twitter': 2, 'Ram': 1, 'yahoo': 3, 'linkedin': 3, 'facebook': 2}
To find out more about lists see the doc
for
statement.website.count(i)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments