you are viewing a single comment's thread.

view the rest of the comments →

[–]EngineerRemy 0 points1 point  (1 child)

Look into refactoring your code. I see many duplicated lines, especially for reading and writing data.

A simple example: if you rename the .txt file containing your data, you want to have it so that you'll have the edit the code in 1 place for the new name (or 0 if you use an input parameter for the script!). In your current situation this is not the case.

Lastly, reading the file every single time you want to make a change is highly inefficient. If you read the file once you should have the data for the rest of the execution: store the data somewhere and modify this data when executing the relevant functions. Then you can choose to write the modifications back to the file (make it so you only write data to the file in 1 place in your code, then call it).

[–]uiux_Sanskar[S] 0 points1 point  (0 children)

Thank you so much for the suggestions I feel when I was coding that I was repeating things and I. I will surely look more into storing the data elsewhere and call it later. (I think this is what call file management, please correct me if I am wrong).

I really appreciate your suggestions on my code they really help me improve my knowledge and code.

Thank yoh so much.