Reputation: 1099
I have a list [1,2,4,7,5,2]
where I want to get rid of the commas to make it [1 2 4 7 5 2]
how would I go about this?
np.random.randint(0,4,12) will print out like [0 3 4 1 3 4 2 1 2 4 3 4]
and thats the kind of thing I want :)
Upvotes: 0
Views: 2576
Reputation: 2569
You could do this:
out = '[' + ' '.join(str(item) for item in numbers)+ ']'
print out
Upvotes: 3
Reputation: 879421
In [7]: data = [1,2,4,7,5,2]
In [11]: '[{}]'.format(' '.join(map(str, data)))
Out[11]: '[1 2 4 7 5 2]'
or,
In [14]: str(data).replace(',','')
Out[14]: '[1 2 4 7 5 2]'
Upvotes: 2