I wrote the code to store history results using python, This code works correctly. but I want to display history the same as the below picture. in this program only shows the output values for history. But I need the entire process of the calculation history not only the final output value. please help me.
Question image Please see the Question
Please look at this image I want to make it as the Expected output.
last_calculation = []
while True:
  print("Select operation.")
  print("1.Add      : + ")
  print("2.Subtract : - ")
  print("3.Multiply : * ")
  print("4.Divide   : / ")
  print("5.Power    : ^ ")
  print("6.Remainder: % ")
  print("7.Terminate: # ")
  print("8.Reset    : $ ")
  print("8.History  : ? ")
  
  def add(x,y):
      return x+y
  def substract(x,y):
      return x-y
  def multiply(x,y):
      return x*y
  def divide(x,y):
      return x/y
  def power(x,y):
      return x**y
  def remainder(x,y):
      return x%y
  def history():
    global last_calculation
    if last_calculation == []:
        print("No past calculations to show")
    else:
        for i in last_calculation:
            print(i)  #for single line
  
 
  # take input from the user
  choice = input("Enter choice(+,-,*,/,^,%,#,$,?): ")
  print(choice)
  if choice == "#":
    #program ends here
    print("Done. Terminating")
    exit()
  if choice == "$":
    continue
  if choice=='?':
   history()
   continue
  try:
    a=input("Enter first number: ")
    print(a)
    if a == "#":
      #program ends here
      print("Done. Terminating")
      exit()
    a=float(a)
        
    b=input("Enter second number: ")
    print(b)
    if b == "#":
      #program ends here
      print("Done. Terminating")
      exit()
    b=float(b)
        
  except ValueError:
   continue
  if choice == "+":
      result = add(a, b)
      last_calculation.append(result)
      print(a, '+', b, '=', add(a,b))
      
  elif choice == "-":
      result = substract(a, b)
      last_calculation.append(result)
      print(a, "-", b, "=", substract(a,b))
  elif choice == "*":
      result = multiply(a, b)
      last_calculation.append(result)
      print(a, "*", b, "=", multiply(a,b))
  elif choice == "/":
      if b == 0.0:
          last_calculation.append(result)
          print("float division by zero")
          print(a, "/", b, "=" " None")
      else:
          result =  divide(a, b)
          last_calculation.append(result)
          print(a, "/", b, "=", divide(a,b)) 
       
  elif choice == '^':
      result = power(a, b)
      last_calculation.append(result)
      print(a, "^", b, "=", power(a,b))
  elif choice == "%":
      result = remainder(a, b)
      last_calculation.append(result)
      print(a, "%", b, "=", remainder(a,b))
  else :
      print("Unrecognized operation")
 
    