暗号文は、重複した文字とその出現率を出力するために使用した文字列です。コードは次のとおりです。
def freq_attack (ciphertext):
store = ""
character = ""
non_character=""
for i in xrange(len(ciphertext)):
x = ciphertext[i]
if(is_alphabet(x)):
character +=x
else:
non_character +=x
for char in character:
count =(ciphertext.count(char)*100)/len(character)
print char, count,"%"
出力は
a 400/7 %
s 100/7 %
a 400/7 %
a 400/7 %
e 100/7 %
a 400/7 %
w 100/7 %