[Solved] Why is len(file.read()) giving me a value of zero?


Files act like a long tape in a casette; you can read the file but by the time you are done you have passed the tape all the way to the end. Reading again won’t give you the data again.

As such your second function tried to read data from a file that is already wound all the way to the end.

You can rewind the ‘tape’ by re-opening the file, or by using target.seek(0) to send it back to the start.

7

solved Why is len(file.read()) giving me a value of zero?