0

Hello helpful people of the internet!

I'm trying to write a file that allows me to calculate savings.

I wanted to be able to save a starting amount to a file (ideally txt or csv as I have some experience working with them) then run a program to add numbers to the saved number. For example if my starting value was 20 and I added 3 the new saved value should be 23 so when the program was run again values would be added to 23.

Nothing I've tried has word so far and I have only had error messages stating my file (containing only the number 20) was a string

Does anybody know how I can do this? Am I using the wrong types of file or is this impossible to do on python?

  • 1
    All your files contain bytes, not numbers or strings. How those bytes are interpreted when you read the file is the key. Ask Python to read those bytes and interpret them as numbers. It works. People do math using data from files in Python all the time. That's why it's so popular for machine learning. – duffymo Jan 25 '20 at 17:14
  • Adding your attempt and the error message would help, – GoodDeeds Jan 25 '20 at 17:15
  • 1
    “Nothing I’ve tried has word so far” - if you update your question with the code you’ve tried so far then people will be able to tell you where you’re going wrong and how to fix your current code. – CDJB Jan 25 '20 at 17:15

0 Answers0