import string def decalage(lettre,clef): liste=list(string.ascii_lowercase)*2 + list(string.ascii_uppercase)*2 if lettre not in liste: return lettre else: return liste[liste.index(lettre)+clef] msg_chiffre = str() while True: msg = input('Entrez le texte à chiffrer (q pour quitter) : ') if msg.lower() == "q": print("bye") exit() clef = int(input('Entrez votre clef : ')) for lettre in msg: msg_chiffre += decalage(lettre,clef) print(msg_chiffre) msg_chiffre = ""