Reputation: 2967
strs = ['x=1', 'b=4', 'x=4']
I want to get:
str = 'x=1 AND b=4 AND x=4'
What is a simplest way to do that in Python?
P.S. too stupid question
Found:
' AND '.join( strs )
Upvotes: 1
Views: 163
Reputation: 43447
You answered you own question, join
is the way to do this.
' '.join(strs)
Will put a space between each item in strs. And the following:
' AND '.join(strs)
Will put ' AND ' between each item.
Upvotes: 2
Reputation: 133534
>>> strs = ['x=1', 'b=4', 'x=4']
>>> print ' AND '.join(strs)
x=1 AND b=4 AND x=4
Upvotes: 8