1234567891011121314151617181920212223242526 |
- # coding: utf-8
- def ceasar(str, n):
- res = ''
- for c in str:
- res += shift(c, n)
- return res
- def shift(c, n):
- if c >= 'a' and c <= 'z':
- base = ord('a')
- elif c >= 'A' and c <= 'Z':
- base = ord('A')
- else:
- base = None
- if base is None:
- return c
- else:
- return chr((ord(c) + n - base) % 26 + base)
- str = input('the ceasar code u want to decode: ')
- for i in range(26):
- print(ceasar(str, i + 1), '\n\n')
|