from collections import Counter def crack_caesar(ciphertext): counts = Counter(ciphertext.upper()) most_common_letter = counts.most_common(1)[0][0] alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" shift = (alphabet.index(most_common_letter) - alphabet.index("E")) % 26 return shift