关于Python列表的一个程序

img


注意以上两个要求
且不运用递归算法

def merge(L1, L2):
  result = []
  L1_i = 0;
  L2_i = 0;

  while(True) {
    if L1[L1_i] > L2[L2_i]:
      result.append(L1[L1_i])
      L1_i += 1
    else:
      result.append(L2[L2_i])
      L2_i += 1
    if L1_i == len(L1) or L2_i == len(L2):
      break
  for i in range(L1_i, len(L1):
    result.append(L1[i])
  for i in range(L2_i, len(L2):
    result.append(L2[i])
  return result