import cs50
import sys
import string
def main():
# checks if there are two arguments
if len(sys.argv) != 2:
print("Incorrect amount of arguments")
return 1
# converts argument to key
key = int(sys.argv[1]) % 26
# gets text input from user
plain = cs50.get_string("plaintext: ")
# displays the first part of ciphertext
print("ciphertext: ", end='')
# loops through each character
for i in range(len(plain)):
if plain[i].isalpha:
if plain[i].isupper:
cipher = ((ord(plain[i]) + key - 65) % 26) + 65
print(chr(cipher), end='')
else:
cipher = ((ord(plain[i]) + key - 97) % 26) + 97
print(chr(cipher), end='')
else:
print(plain[i], end='')
print("")
return 0
if __name__ == '__main__':
main()