Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

How can you make python not to forget your progress?

+6 votes
asked May 17, 2023 by Eidnoxon (5,160 points)
For example: You have made a typing test using python. You try your program and you get 80WPM. Now you stop your program, and on the next day, you try that again. Now I need my program to remember my yesterday's  progress, and print it out in the corner or whereever. I would appreciate it :D. (Also, english isn't my native language, so I understand if you don't understand my english :D)

1 Answer

0 votes
answered May 17, 2023 by Peter Minarik (87,810 points)

As the program terminates, all of the assigned memory is cleared, including the running state.

So what can you do?

Save the state than you want and store it in permanent storage that survives the execution of the program. So not in memory, but for instance on disc or in an online service. Let's stick with the disc as the most obvious choice.

You'll need to look into file management with Python. How to save content to a file, and how to load content from a file.

Look into this tutorial, start with open() then check out read() and write().

Good luck!

Note: any file created should be added to your OnlineGDB project to prevent the server from removing resources after you're done with your work. Running things on your local PC does not need such considerations. ;)

commented May 18, 2023 by Eidnoxon (5,160 points)
Thank you for helping me out :D
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.