1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| #!/usr/bin/python3.4
# -*-coding: utf-8 -*-
# script de codage cesar
chaine = ("abcdefghijklmnopqrstuvwxyz")
#help (len)
#help (range)
for i in range (len(chaine)): # fonctionne
#for i in (chaine): renvoi l'erreur indice de chaine doit etre un entier
if chaine[i] == "a":
chaine_decallee = chaine [i+3:] + chaine [i] + chaine [i+1] + chaine [i+2]
# chaine [i+3:] signifie que chaine _decallee commencera à d elimination des 3
#premier arguments de la chaine initiale, et report en fin de chaine ( chaine[i]+chaine[i+1] etc...)
print (chaine_decallee)
messageACoder =("mzntypythons flying circus")
for j in range (len(messageACoder)):
print (j)
u=0
while messageACoder[j] != chaine[u]:
print ("a coder= ", messageACoder[j])
code [j]= chaine_decallee[u]
u+=1
if messageACoder[j] == " ":
break
print("code= ",code) |
Partager