Created
September 19, 2017 21:06
-
-
Save GuiMarthe/57ff9daced41a1bf20c055f8cc67e39f to your computer and use it in GitHub Desktop.
Implementando uma simples cifra de cesar mostrando compreensões de lista e dicionários + alguns métodos de string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import string | |
| letras = string.ascii_lowercase | |
| texto = input('Digite o seu texto: ').lower() | |
| k = int(input('Digite a quantidade de vezes que o seu texto se deslocará: ')) | |
| chave = {letra:letras[(i + k) % len(letras)] for i, letra in enumerate(letras + ' ')} | |
| mensagem_codificada = ''.join([chave[letra] for letra in texto]) | |
| print('A sua mensagem encriptada é: \n{}'.format(mensagem_codificada)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment