In this example we will show how to merge and sort two lists in Python.
Source Code
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
n1 = input("Please input the first list of numbers separated by SPACE: ")
n2 = input("Please input the second list of numbers separated by SPACE: ")
a = n1.split()
b = n2.split()
c = a + b
d = []
for i in c:
d.append(int(i))
d.sort()
print("After merging and sorting: ", d)
Output:
Please input the first list of numbers separated by SPACE: 5 8 6
Please input the second list of numbers separated by SPACE: 2 9 3
After merging and sorting: [2, 3, 5, 6, 8, 9]