def encrypt(text, rot): encrypted = "" for ch in text: encrypted += rotate_character(ch, rot) return encrypted
def encrypt(text, rot): encrypted_text = "" for i in text: encrypted_text = encrypted_text + rotate_character(i, rot) return encrypted_text
def encrypt(text, rot): alphabet = "abcdefghijklmnopqrstuvwxyz" encrypted_string = "" for character in text: encrypted_string += rotate_character(character, rot) return encrypted_string
def encrypt(text, rot): encrypted = '' for char in text: encrypted += rotate_character(char, rot) return encrypted
def encrypt(text, rot): new_text = '' for i in text: new_text = new_text + rotate_character(i, rot) return new_text
def encrypt(text, rot): a_list = [char for char in text] return ''.join(rotate_character(item, rot) for item in a_list)
def encrypt(text, rot): new_text = "" for i in text: new_text += rotate_character(i, rot) return "".join(new_text)
def encrypt(text, rot): x = "" for n in text: x = x + rotate_character(n, rot) return (x)
def encrypt(text, rot): result = "" for i in text: result += rotate_character(i, rot) return result
def encrypt(text, rot): encrypted_message = '' for i in text: encrypted_message += rotate_character(i, rot) return encrypted_message
def encrypt(text, rot): alphabet_position(text) encrypted_message = rotate_character(text, rot) return encrypted_message
def encrypt(text, rot): return "".join([rotate_character(char, rot) for char in text])
def encrypt(text, rot): new_message = '' for letter in text: new_message += rotate_character(letter, rot) return new_message
def encrypt(text, rot): new_str = "" for letter in text: new_str += rotate_character(letter, rot) return new_str
def my_test(): """ Cursory testing of caesar.py functions """ # alphabet_position(letter) print("Testing alphabet_position(letter)...\n") my_test_equal(alphabet_position('a'), 0) my_test_equal(alphabet_position('A'), 0) my_test_equal(alphabet_position('b'), 1) my_test_equal(alphabet_position('y'), 24) my_test_equal(alphabet_position('z'), 25) my_test_equal(alphabet_position('Z'), 25) print() # rotate_character(char, rot) print("Testing rotate_character(char, rot)...\n") my_test_equal(rotate_character('a', 13), 'n') my_test_equal(rotate_character('a', 14), 'o') my_test_equal(rotate_character('a', 0), 'a') my_test_equal(rotate_character('c', 26), 'c') my_test_equal(rotate_character('c', 27), 'd') my_test_equal(rotate_character('A', 13), 'N') my_test_equal(rotate_character('z', 1), 'a') my_test_equal(rotate_character('Z', 2), 'B') my_test_equal(rotate_character('z', 37), 'k') my_test_equal(rotate_character('!', 37), '!') my_test_equal(rotate_character('6', 13), '6') print() # encrypt(text, rot) print("Testing encrypt(text, rot)...\n") my_test_equal(encrypt('a', 13), 'n') my_test_equal(encrypt('abcd', 13), 'nopq') my_test_equal(encrypt('LaunchCode', 13), 'YnhapuPbqr') my_test_equal(encrypt('LaunchCode', 1), 'MbvodiDpef') my_test_equal(encrypt('Hello, World!', 5), 'Mjqqt, Btwqi!') print()
def encrypt(text, rot): a = '' b = (int(rot)) for i in text: a = a + (rotate_character(i, b)) return a
def encrypt(text, rot): new_text = "" for char in text: new_text = new_text + rotate_character(char, rot) return new_text
def encrypt(text, rot): encrypt_text = '' for x in text: encrypt_text = encrypt_text + rotate_character(x, rot) return encrypt_text
def encrypt(text, rot): encrypted_text = "" for char in text: encrypted_text += rotate_character(char, rot) return encrypted_text
def encrypt(text, rot): new_string = [] for i in text: new_string.append(helpers.rotate_character(i, rot)) return "".join(new_string)
def encrypt(text, rot): new_string = "" for char in text: new_string += rotate_character(char, rot) return new_string
def rotate_string(text, rot): ''' This is the actual function that does the job! - more comment ''' result = '' for c in text: result += rotate_character(c, rot) return result
from sys import argv, exit print("I know that these are the words the user typed on the command line: ", argv) from helpers import rotate_character message = input("Enter your message: ") rot = int(input("How much do you want to rotate by? ")) def user_input_is_valid(cl_args): if (str(cl_args).isdigit()): return True # elif (len(cl_args) < 2): # return False else: return False exit() def main(): input_valid = user_input_is_valid(args[1]) if input_valid == True: msg = input("Type a message: \n") return(rotate_character(msg, int(args[1]))) else: return("Usage: python3 caesar.py n") print(rotate_character(message, rot))
def encrypt(text, rot): encrypted_text = [] for i in text: encrypted_text.append(rotate_character(i, rot)) new_text = "".join(encrypted_text) return new_text
def encrypt(text, rot): encrypted_str = '' for i in range(len(text)): encrypted_str += rotate_character(text[i], rot) return encrypted_str
def encrypt(text, rot): list1 = "" for char in text: list1 += rotate_character(char, rot) return list1
def encrypt(text, rot): rotated_text = '' for char in text: rotated_text += rotate_character(char, rot) return rotated_text
def encrypt(text, rot): encryptText = "" for i in range(len(text)): temp = rotate_character(text[i], (rot % 13)) encryptText = encryptText + temp return encryptText
def encrypt(text, rot): encode_text = '' for c in text: encode_text += rotate_character(c, rot) return encode_text
def rotate_string(text, rot): strRet = "" for c in text: strRet += rotate_character(c, rot) return strRet