input: Write a function to find the longest common subsequence between two given strings. The function should return the longest common subsequence as a string. If either of the input strings is empty, return an empty string.
  
  def longest_common_subsequence(string1, string2):
      table = [[0]*(len(string2)+1) for _ in range(len(string1)+1)]
  
      for i, x in enumerate(string1):
          for j, y in enumerate(string2):
              if x == y:
                  table[i+1][j+1] = table[i][j]+1
              else:
                  table[i+1][j+1] = max(table[i+1][j], table[i][j+1])
  
      result = ""
      x, y = len(string1), len(string2)
      while x != 0 and y != 0:
          if table[x][y] == table[x-1][y]:
              x -= 1
          elif table[x][y] == table[x][y-1]:
              y -= 1
          else:
              result = string1[x-1] + result
              x -= 1
              y -= 1
      return result
  
  assert longest_common_subsequence("ABCDF", "ABECD") == "ABCD"
  assert longest_common_subsequence("AGGTAB", "GXTXAYB") == "GTAB"
  assert longest_common_subsequence("", "ABECD") == ""
  assert longest_common_subsequence("ABCDF", "") == ""
  assert longest_common_subsequence("ABC", "ABC") == "ABC"
output: def longest_common_subsequence(string1, string2):
      if not string1 or not string2:
          return ""
      
      table = [[0]*(len(string2)+1) for _ in range(len(string1)+1)]
  
      for i, x in enumerate(string1):
          for j, y in enumerate(string2):
              if x == y:
                  table[i+1][j+1] = table[i][j]+1
              else:
                  table[i+1][j+1] = max(table[i+1][j], table[i][j+1])
  
      result = ""
      x, y = len(string1), len(string2)
      while x != 0 and y != 0:
          if table[x][y] == table[x-1][y]:
              x -= 1
          elif table[x][y] == table[x][y-1]:
              y -= 1
          else:
              result = string1[x-1] + result
              x -= 1
              y -= 1
      return result