X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=norms.py;h=66452940c376658e446bb704c7198ee1ace2be22;hb=3ba8a3b82ccec64a2939708f428354176af6746e;hp=b8e4bf1ef82c8b8ea6f85c0e3c3597d90b7d9b8b;hpb=96d46a680a808555a9ff77f2eaa68383569f07ee;p=cipher-training.git diff --git a/norms.py b/norms.py index b8e4bf1..6645294 100644 --- a/norms.py +++ b/norms.py @@ -13,7 +13,7 @@ def normalise(frequencies): >>> sorted(normalise({1: 1, 2: 2, 3: 1}).items()) [(1, 0.25), (2, 0.5), (3, 0.25)] """ - length = sum([f for f in frequencies.values()]) + length = sum(f for f in frequencies.values()) return collections.defaultdict(int, ((k, v / length) for (k, v) in frequencies.items()))