mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-01-19 00:37:02 +00:00
Merge pull request #46 from Henocks/patch-2
Slight Performance/Visual Update
This commit is contained in:
commit
3f505c5b39
|
@ -17,13 +17,6 @@ def main():
|
|||
print("Decryption:", translated)
|
||||
|
||||
def encdec(message, key, mode):
|
||||
"""
|
||||
>>> encdec('Harshil Darji', 12, 'encrypt')
|
||||
'TMDETUX PMDVU'
|
||||
|
||||
>>> encdec('TMDETUX PMDVU', 12, 'decrypt')
|
||||
'HARSHIL DARJI'
|
||||
"""
|
||||
message = message.upper()
|
||||
translated = ""
|
||||
LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
@ -36,13 +29,13 @@ def encdec(message, key, mode):
|
|||
num = num - key
|
||||
|
||||
if num >= len(LETTERS):
|
||||
num = num - len(LETTERS)
|
||||
num -= len(LETTERS)
|
||||
elif num < 0:
|
||||
num = num + len(LETTERS)
|
||||
num += len(LETTERS)
|
||||
|
||||
translated = translated + LETTERS[num]
|
||||
translated += LETTERS[num]
|
||||
else:
|
||||
translated = translated + symbol
|
||||
translated += symbol
|
||||
return translated
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Reference in New Issue
Block a user