-> replaced un-changed lists by tuples for better runtime & memory savings.
-> removed str conversion ahead of input as it always returns a string.
-> optimized for loops & converted un-changed list comprehensions into generator for better memory savings.
-> removed unnecessary '!=0' references in if-blocks.
-> removed unnecessary 'return None' statements.
-> converted classic strings formatting into f-strings for better runtime.
-> switched '.lower().strip()' -> '.strip().lower()' for better runtime.
-> other minor optimizations.
Made the following changes:
-> replaced un-changed lists by tuples for better runtime & memory savings. -> removed str conversion ahead of input as it always returns a string. -> optimized for loops & converted un-changed list comprehensions into generator for better memory savings. -> removed unnecessary '!=0' references in if-blocks. -> removed unnecessary 'return None' statements. -> converted classic strings formatting into f-strings for better runtime. -> switched '.lower().strip()' -> '.strip().lower()' for better runtime. -> other minor optimizations.