-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodCesarDicc.py
More file actions
27 lines (18 loc) · 816 Bytes
/
codCesarDicc.py
File metadata and controls
27 lines (18 loc) · 816 Bytes
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
#diccAbecedario = { "a":,"b","c","d","e","f","g","h","i","j","k","l","m","n","ñ","o","p","q","r","s","t","u","v","w","x","y","z" }
desplazamiento = 6
alfabeto = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".lower()
abecedario = {}
for letra in alfabeto:
posicion = alfabeto.index(letra)
nuevaPosicion = posicion + desplazamiento
if nuevaPosicion >= len(alfabeto):
nuevaPosicion=abs(len(alfabeto)-nuevaPosicion)
abecedario.update( { letra: alfabeto[nuevaPosicion] } )
entradaUsuario = input("introduce un texto: ").lower()
textoCifrado= ""
for letra in entradaUsuario:
if letra in list(abecedario.keys()):
textoCifrado += abecedario[letra]
else: #Si pongo una coma, o un espacio, no traduce, lo respeta, porque no esta en el abecedario
textoCifrado+=letra
print(textoCifrado)