Advertisement
Guest User

Untitled

a guest
Aug 13th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. alfabeto = 'qwertyuiopasdfghjklzxcvbnm'
  2.  
  3. lista_alfabeto = sorted(alfabeto)
  4.  
  5. ##frase = frase.replace('k','m')
  6. ##frase = frase.replace('o','q')
  7. ##frase = frase.replace('e','g')
  8.  
  9. def traduz(frase):
  10.     traducao = ''
  11.     for letra in frase:
  12.         if letra not in alfabeto:
  13.             traducao += letra
  14.         else:
  15.             indice = lista_alfabeto.index(letra) + 2
  16.             if indice >= len(alfabeto):
  17.                 indice = indice - len(alfabeto)
  18.             traducao += lista_alfabeto[indice]
  19.            
  20.     frase = traducao
  21.     print frase
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement