The os module isnt renaming a file [os.rename (file1, file2)]

Question:

def modify_email_i(v):
  c = 0
  file = open('investor.dat', 'rb')
  file1 = open('temp1.dat', 'wb')

  try:
    while True:
      a = pickle.load(file)
      if (a[3]) != v:
        pickle.dump(a, file1)
        break
      elif a[3] == v:

        email_i_new = input("Please enter the New Email :")
        list1 = [a[0], a[1], a[2], email_i_new, a[4], a[5]]
        pickle.dump(list1, file1)
        c = 1
  except EOFError:
    file.close()
    file1.close()
    os.remove('investor.dat')
    os.rename('temp1.dat', 'investor.dat')
    return c

Hi @J-SreejithSreej welcome to the community.

Can you post a link to your Repl please? I’m assuming that the code segment you posted is not the entire program.