Home > Enterprise >  how to remove square brackets in my print statement
how to remove square brackets in my print statement

Time:11-10

Sort the k arrays individually and concatenate them. Input Description: First line contains the number of arrays. Subsequent lines contain the size of the array followed by the elements of the array.

Output Description: An array containing the sorted elements of k sorted arrays

Sample Input : 3 2 98 12 6 1 2 3 8 5 9 1 11 Sample Output : 12 98 1 2 3 5 8 9 11


a=input()
b=input()
c= input().split()
C=str(sorted(c))
d=input()
e=input().split()
E=str(sorted(e))
f=input()
g=input().split()
G=str(sorted(g))
x=C E G
print(*x)````

#output
[ ' 1 2 ' ,   ' 9 8 ' ] [ ' 1 ' ,   ' 2 ' ,   ' 3 ' ,   ' 5 ' ,   ' 8 ' ,   ' 9 ' ] [ ' 1 1 ' ]````
`desired output`
#i want my output as
Sample Output :
12 98 1 2 3 5 8 9 11

CodePudding user response:

import re

val = "[ ' 1 2 ' , ' 9 8 ' ] [ ' 1 ' , ' 2 ' , ' 3 ' , ' 5 ' , ' 8 ' , ' 9 ' ] [ ' 1 1 ' ]"

print(re.sub(r'[^\w]', ' ', val))

CodePudding user response:

x = C   E   G
x = x.replace('[', '').replace(']', ' ').replace("'", '').replace(',', '')
print(x)

hope it will work

  • Related