-
Couldn't load subscription status.
- Fork 1
L2.0
Stac edited this page Mar 10, 2019
·
3 revisions
# 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?
Feel free to browse the wiki using the index on your right-hand side.