-> 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 'return None' statements.
-> 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 'return None' statements. -> switched '.lower().strip()' -> '.strip().lower()' for better runtime. -> other minor optimizations.