In python It's more recommended to open files with a context manager so in cases of any unexpected error, context manager can handle situation and close the files properly. it could also close the file or files automatically after completed operation. and therefore cleaner and more readable code were provided. also some variable name improvement and some indentations fixes done.
In python It's more recommended to open files with a context manager so in cases of any unexpected error, context manager can handle situation and close the files properly. it could also close the file or files automatically after completed operation. and therefore cleaner and more readable code were provided. also some variable name improvement and some indentations fixes done.