i am trying to perform both read and write operations in a python text file by opening it into r+ mode. However, irrespective of how many characters i read (say 'fo.read(5)') before performing performing the write operation (say 'fo.write("random")'), the text is written/appended at the end of the file.
fo = open("C:/Users/Dell/Desktop/files/new.txt",'r+')
fo.read(5)
fo.write('random')
fo.close()
i expected the text being written ('random' in this example) to be written 6th character onward but instead got written/appended at the end of the text file. what can be the possible explanation for this behaviour?