#! /usr/bin/python3 # -*- coding: utf-8 -*- def carot13(lettre): """retourne la lettre correspondante en rot13, on suppose que lettre est entre a et z""" n=ord(lettre)-97 m=(n+13)%26 rot=chr(m+97) return rot def marot13(mot): """retourne le mot correspondant en rot13, on suppose que le mot est composé de lettres entre a et z""" out=""; for lettre in mot: out+=carot13(lettre) return out # test print("rot13") print("abcdefghijklmnopqrstuvwxyz") print(marot13("abcdefghijklmnopqrstuvwxyz")) print(marot13(marot13("abcdefghijklmnopqrstuvwxyz"))) def rot13(phrase): """retourne la phrase correspondant en rot13, on suppose que la phrase est composée de mots séparés par un espace et composé de lettres entre a et z""" maListeDeMots=phrase.split() listeDeMotsEnRot13=[marot13(mot) for mot in maListeDeMots] phraseEnRot13=" ".join(listeDeMotsEnRot13) return phraseEnRot13 message="the lazy dog jumped over the quick brown fox" print() print("test") print(message) print(rot13(message)) print(rot13(rot13(message)))