科技小组分2个小队搜集到西红柿生长的数据信息。2个小队将数据进行了从小到大排序: a = [1,3,4,6,7,13,17,21], b = [2,5,6,8,10,12,14,16,18] ,请明明将这2个小队的数据进行合并,生成为一个从小到大有序的列表。
输入:
1,3,4,6,7,13,17,21
2,5,6,8,10,12,14,16,18
输出:
[1,2,3,4,5,6,6,7,8,10,12,13,14,16,17,18,21]
请帮明明编写程序实现上述功能,或补全代码。
x = input() s = x.split(',') a=[] for i in range( ① ): a.append(int(s[i])) y = input() s = y. ② b=[] for i in range(len(s)): b.append(int(s[i])) ret = [] i = j = 0 while len(a) >= i + 1 and ③ : if a[i] <= b[j]: ④ i += 1 else: ret.append(b[j]) j += 1 if len(a) > i: ret += a[i:] if len(b) > j: ⑤ print(ret)