Skip to content

Instantly share code, notes, and snippets.

@KatUser
Created July 22, 2020 08:09
Show Gist options
  • Save KatUser/a27bfec6ababe19e6a2d7fe74c904746 to your computer and use it in GitHub Desktop.
Save KatUser/a27bfec6ababe19e6a2d7fe74c904746 to your computer and use it in GitHub Desktop.
Ceaser_decoder
en_alphabet = [x for x in range(ord('a'), ord('z') + 1)]
s = input()
whitespace = 'whitespace'
s = s.replace(' ', ' whitespace')
s = s.split(whitespace)
for word in s:
counter = 0
for symbol in word:
if ord(symbol.lower()) in en_alphabet:
counter = counter + 1
for symbol in word:
if ord(symbol.lower()) in en_alphabet:
if ord(symbol.lower()) + counter in en_alphabet:
if symbol == symbol.upper() in word:
print(chr(ord(symbol.lower()) + counter).upper(), end='')
else:
print(chr(ord(symbol.lower()) + counter), end='')
else:
if symbol == symbol.upper() in word:
print(chr(ord(symbol.lower()) + counter - len(en_alphabet)).upper(), end='')
else:
print(chr(ord(symbol.lower()) + counter - len(en_alphabet)), end='')
else:
print(symbol, end='')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment