Need to try and count repeated lists within a list

Posted by user1828603 on Stack Overflow See other posts from Stack Overflow or by user1828603
Published on 2012-11-16T04:50:01Z Indexed on 2012/11/16 5:00 UTC
Read the original article Hit count: 228

Filed under:

Im trying to count how many repeated lists there are inside a list. But it doesnt work the same way I could count repeated elements in just a list. Im fairly new to python, so apologies if it sounds too easy.

this is what i did

x=  [["coffee", "cola", "juice" "tea" ],["coffee", "cola", "juice" "tea"]
["cola", "coffee", "juice" "tea" ]]
dictt= {}

for item in x:

    dictt[item]= dictt.get(item, 0) +1

return(dictt)

© Stack Overflow or respective owner

Related posts about python