Oct-25-2018, 01:18 PM
you open and close the test.txt every time you write in it. However the mode is 'w'. i.e. if the file exists it is replaced by new file. that is why you get just the last entry. use mode 'a' or you can open the file at the beginning and close it after you end iterating over the files. The drawback is you will get empty file if no file match the condition
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs