From 467b21111e45f4e47d43c9e228256a85ad0c2899 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Wed, 10 Apr 2024 17:57:04 +0800 Subject: optimized what happens if its not in the dictionary --- __pycache__/stdlib.cpython-312.pyc | Bin 11037 -> 11037 bytes main.py | 17 ++++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/__pycache__/stdlib.cpython-312.pyc b/__pycache__/stdlib.cpython-312.pyc index 74732eb..e12a634 100644 Binary files a/__pycache__/stdlib.cpython-312.pyc and b/__pycache__/stdlib.cpython-312.pyc differ diff --git a/main.py b/main.py index b2fc23e..54f5db8 100644 --- a/main.py +++ b/main.py @@ -116,9 +116,6 @@ def main(): transmode = 1 reverseMode(in_data) -def outputter(data): - aprintf(data) - def normalMode(data: str): """ @@ -135,8 +132,11 @@ def normalMode(data: str): global in_data, out_data aprintf("Mode selected: Normal Mode") for i in data: - out_data += list(map.keys())[list(map.values()).index(i)] - outputter(out_data) + try: + tmp = list(map.keys())[list(map.values()).index(i)] + except ValueError: + tmp = i + printf(tmp) @@ -145,8 +145,11 @@ def reverseMode(data: str): global in_data, out_data aprintf("Mode selected: Reverse Mode") for i in data: - out_data += map[i] - outputter(out_data) + try: + tmp = map[i] + except KeyError: + tmp = i + printf(tmp) if __name__ == '__main__': in_data = keepasks("What is the data you want to transfer?", inputter=askinput) -- cgit v1.2.3