2009-11-08から1日間の記事一覧
続いて第2問。 ソースに「find rare characters in the mess below」とあるので文字毎の出現回数を数えてみる。 def count(str): counter = {} for s in str: counter[s] = counter.get(s, 0) + 1 print(counter) if __name__ == '__main__': count(open('ch…
続いて第2問。 ソースに「find rare characters in the mess below」とあるので文字毎の出現回数を数えてみる。 def count(str): counter = {} for s in str: counter[s] = counter.get(s, 0) + 1 print(counter) if __name__ == '__main__': count(open('ch…