-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRotchar.py
More file actions
27 lines (19 loc) · 729 Bytes
/
Copy pathRotchar.py
File metadata and controls
27 lines (19 loc) · 729 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
27
word = input("Quel mot voulez vous encoder ?")
rot = int(input("Quel est la méthode rotchar que vous voulez utiliser (1-26)"))
i = 0
letter_temp = ""
final_word = ""
letter = ["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"]
#Pour trouver la position d'une lettre
def position(letter_temp):
return ord(letter_temp.lower()) - ord('a')
while i < len(word):
letter_temp = word[i]
pos = position(letter_temp)
print(pos)
nb_rot = pos + rot
letter_rot = nb_rot % 26
letter_rot_final = letter[letter_rot]
final_word = str(final_word) + str(letter_rot_final)
i = i + 1
print(final_word)