我有这样的名单:另一种方法来计算出现在列表中
['Boston Americans', 'New York Giants', 'Chicago White Sox', 'Chicago Cubs', 'Chicago Cubs', 'Pittsburgh Pirates', 'Philadelphia Athletics', 'Philadelphia Athletics', 'Boston Red Sox', 'Philadelphia Athletics', 'Boston Braves', 'Boston Red Sox', 'Boston Red Sox', 'Chicago White Sox', 'Boston Red Sox', 'Cincinnati Reds', 'Cleveland Indians', 'New York Giants', 'New York Giants', 'New York Yankees', 'Washington Senators', 'Pittsburgh Pirates', 'St. Louis Cardinals', 'New York Yankees', 'New York Yankees', 'Philadelphia Athletics', 'Philadelphia Athletics', 'St. Louis Cardinals', 'New York Yankees']
说我想算"Boston Americans"
多少次是在列表中。
我该怎么做,而不使用.count
方法list.count("Boston Americans")
或任何导入?
“我怎么能做到这一点,而不使用计数法” – CoryKramer 2014-12-03 17:55:24
ohhh :)我dident看到我谢谢 – Hackaholic 2014-12-03 17:55:55
或只是collections.Counter?.. – shx2 2014-12-03 18:02:59