6) array error with sort(reverse = true)
Created 2 years ago
216
Views
4
Comments
You are given with two arrays. Your task is to merge the array such that first array is in ascending order and second one in descending order.
Input Description:
First line contains two integer ‘n’ and ‘m’. ‘n’ denotes length of array 1 and ‘m’ of array 2.Next line contains n space separated numbers and third line contains ‘m’ space separated numbers
Output Description:
Print a single array in desired order
Sample Input :
3 3
23 15 16
357 65 10
Sample Output :
15 16 23 357 65 10
my code is:
n, m = input().split()
N = input().split()
M = input().split()
N.sort()
M.sort(reverse=True)
L = N + M
print(L)
ERROR:
but it is printing merged second list as
['15', '16', '23', '65', '357', '10']
kindly give a correct syntax so that second list is in descending order