I\'m pretty new to Python and am completely confused by .join()
which I have read is the preferred method for concatenating strings.
I tried:
To expand a bit more on what others are saying, if you wanted to use join to simply concatenate your two strings, you would do this:
strid = repr(595)
print ''.join([array.array('c', random.sample(string.ascii_letters, 20 - len(strid)))
.tostring(), strid])
list = ["my", "name", "is", "kourosh"]
" ".join(list)
If this is an input, using the JOIN method, we can add the distance between the words and also convert the list to the string.
This is Python output
'my name is kourosh'
On providing this as input ,
li = ['server=mpilgrim', 'uid=sa', 'database=master', 'pwd=secret']
s = ";".join(li)
print(s)
Python returns this as output :
'server=mpilgrim;uid=sa;database=master;pwd=secret'