-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcaesar_cypher.py
35 lines (27 loc) · 877 Bytes
/
caesar_cypher.py
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
28
29
30
31
32
33
34
35
# --------------------------------------------------------
#
# Caesar Cypher (Mark Anthony version)
#
# Folder: session-03
# Filename: caesar_cypher.py
# Author: Adrian Gould <[email protected]>
# Version: 1.0
#
# --------------------------------------------------------
print("Welcome to the Caesar Cypher program")
name = input("What is your name")
print(name, "hope you enjoy encrypting and decrypting words.")
letter = input("Please enter a letter to encrypt: ")
shift = input("Shift by how many characters: ")
try:
shift = int(shift)
except:
error = input("Invalid value for shift, press ENTER to stop")
quit()
if letter.isalpha():
ascii_value = ord(letter)
ascii_value = ascii_value + shift
answer = chr(ascii_value)
print("Caesar cypher letter is", answer)
else:
print("You did not enter a letter to shift")