L2.0 - StackingFlowing/CTProgramming GitHub Wiki
2.0 Encryption Overview
# VARIABLES
dictionary = "abcdefghijklmnopqrstuvwxyz"
encrypting = input("Would you like to encrypt or decrypt? ( e / d ) ")
key = int(input("Enter your key: "))
message = input("Enter your message: ")
newMessage = ""
# FOR LOOP
for character in message:
position = dictionary.find(character)
if encrypting == "e":
newPosition = (position + key)
elif encrypting == "d":
newPosition = (position - key)
newMessage += dictionary[newPosition]
# PRINT
print()
print(newMessage)
Try to run the above code. What does it do?