How to join a array to string in Python

To join a array to string in Python you can use the following snippet.

Sample Python

def JoinArray(input, delimiter, appendToEnd):
	delimiter = ';'
	joinedString = delimiter.join(input)
	if appendToEnd:
		joinedString = joinedString + delimiter
		return joinedString
	else:
		return joinedString

list = ['This', 'is', 'a', 'Test','!']
print JoinArray(list, ';', False)

Please Share us:
Please rate this snippet

2 thoughts on “How to join a array to string in Python

Leave a Reply