Issue
I am trying to print a list like a string:
list = ['a', 'b', 'c', 'd', 'e', 'f']
the output I want it to be;
abcdef
Solution
You should use the join() method, in python, join() returns a string in which the string elements of sequence have been joined by str separator.
str = ''
sequence = ['a', 'b', 'c', 'd', 'e', 'f']
print str.join(sequence)
You can pass any list or tuple as sequence.
Answered By - SpiXel Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.