Skip to content
Snippets Groups Projects
Select Git revision
  • 2a701f3c48e07bd53d7b5451940f3bf7ab7519c3
  • master default protected
2 results

cse16218_ex2_9.py

Blame
  • cse16218_ex2_9.py 399 B
    def encrypt(string, shift):
     
      cipher = ''
      for char in string: 
        if char == ' ':
          cipher = cipher + char
        elif  char.isupper():
          cipher = cipher + chr((ord(char) + shift - 65) % 26 + 65)
        else:
          cipher = cipher + chr((ord(char) + shift - 97) % 26 + 97)
      
      return cipher
     
    s= input("String: ")
    shift = int(input("Shift: "))
    print("Encrypted String: ", encrypt(s, shift))