Created
July 30, 2018 02:11
-
-
Save toshvelaga/825dbf168e9aa5aeb72fe1ef870fb09e to your computer and use it in GitHub Desktop.
CS50 Ceaser python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cs50 import cs50 | |
alphabet = "abcdefghijklmnopqrstuvwxyz" | |
alphabetcap = alphabet.upper() | |
cyphertext = "" | |
word = input("Please enter in a word to be encrypted: ") | |
key = int(input("Please enter a numnber to use as the encryption key: ")) | |
for letter in word: | |
if letter in alphabet: | |
newposition = (alphabet.find(letter) + key) % 26 | |
cyphertext += alphabet[newposition] | |
elif letter in alphabetcap: | |
newposition = (alphabetcap.find(letter) + key) % 26 | |
cyphertext += alphabetcap[newposition] | |
else: | |
cyphertext += letter | |
print(cyphertext) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment