Python Project: Code Generator

CODE

import random

print("Welcome to the Code Generator!\n")

alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'

original_phrase = input("Enter your phrase: ")
coded_phrase = []

key = random.randint(1, 9)

for character in original_phrase:
    if character in alphabet:
        new_position = (alphabet.find(character) + key) % len(alphabet)
        coded_phrase.append(alphabet[new_position])
    else:
        coded_phrase.append(character)

coded_phrase = ''.join(coded_phrase)

print("Coded message: " + coded_phrase)
print("Key: +{}".format(key))