input:
1 20 3
30 10 2
5 11 15
output:
[[1, 2, 3], [5, 10, 11], [15, 20, 30]]
expected output:
1 2 3
5 10 11
15 20 30
inputLine1 = '1 20 3'
inputLine2 = '30 10 2'
inputLine3 = '5 11 15'
inputList = [inputLine1, inputLine2, inputLine3]
for i in range(len(inputList)):
# Split input line into a list
inputList[i] = inputList[i].split()
# Convert each item in input line into integer
inputList[i] = [int(item) for item in inputList[i]]
# List containing the elements of all lists in the input list
mergedInputList = []
for l in inputList:
mergedInputList.extend(l)
mergedInputList.sort()
# Display output
for i in range(len(mergedInputList)):
end = ' '
if (i + 1) % 3 == 0:
end = '\n'
print(mergedInputList[i], end=end)
Comments
Leave a comment