There is a list of strings, you need to stitch everything into one. For example:
>>> string_list = ['foo', 'bar', 'eggs'] >>> ... 'foobareggs' Is there any built-in method in Python for this task?
If not, how to implement it?
There is a list of strings, you need to stitch everything into one. For example:
>>> string_list = ['foo', 'bar', 'eggs'] >>> ... 'foobareggs' Is there any built-in method in Python for this task?
If not, how to implement it?
The string has a join method.
>>> string_list = ['foo', 'bar', 'eggs'] >>> ''.join(string_list) 'foobareggs' If the method / function is missing / not familiar, you can always implement a bicycle with something like:
reduce (lambda x, y: x + y, string_list)
, but such questions will be easily solved if you pass - for example, the basics on the codeacademy - an easy, free and useful course
Source: https://ru.stackoverflow.com/questions/597900/
All Articles