Re: Concatenate list values
Many thanks for those you chose to help me out. Problem solved. -- https://mail.python.org/mailman/listinfo/python-list
Re: Concatenate list values
loial wrote: Is there a quick way to concatenate all the values in a list into a string, except the first value? I want this to work with variable length lists. All values in list will be strings. Any help appreciated strings ['All', 'values', 'in', 'list', 'will', 'be', 'strings'] Build a new list without the first item: strings[1:] ['values', 'in', 'list', 'will', 'be', 'strings'] Concatenate the strings: |.join(strings[1:]) 'values|in|list|will|be|strings' If you don't want a separator invoke the join method on an empty string: .join(strings[1:]) 'valuesinlistwillbestrings' -- https://mail.python.org/mailman/listinfo/python-list
Re: Concatenate list values
In 12821378-62af-4954-8b61-aa0738c5f...@googlegroups.com loial jldunn2...@gmail.com writes: Is there a quick way to concatenate all the values in a list into a string, except the first value? I want this to work with variable length lists. All values in list will be strings. Any help appreciated big_string = ', '.join(my_list[1:]) -- John Gordon Imagine what it must be like for a real medical doctor to gor...@panix.comwatch 'House', or a real serial killer to watch 'Dexter'. -- https://mail.python.org/mailman/listinfo/python-list
Re: Concatenate list values
On 2015-02-23 07:58, loial wrote: Is there a quick way to concatenate all the values in a list into a string, except the first value? I want this to work with variable length lists. All values in list will be strings. Using .join(my_list[1:]) should work. If it is an arbitrary iterable instead of a list (and thus can't be sliced), you can use .join(itertools.islice(my_iter, 1, None)) -tkc -- https://mail.python.org/mailman/listinfo/python-list
Re: Concatenate list values
On Mon, 23 Feb 2015 07:58:39 -0800, loial wrote: Is there a quick way to concatenate all the values in a list into a string, except the first value? I want this to work with variable length lists. All values in list will be strings. Any help appreciated ''.join(mylist[1:]) all elements must be strings (as specified) or it will cause an error -- petribar: Any sun-bleached prehistoric candy that has been sitting in the window of a vending machine too long. -- Rich Hall, Sniglets -- https://mail.python.org/mailman/listinfo/python-list
Concatenate list values
Is there a quick way to concatenate all the values in a list into a string, except the first value? I want this to work with variable length lists. All values in list will be strings. Any help appreciated -- https://mail.python.org/mailman/listinfo/python-list
Re: Concatenate list values
On 2015.02.23 09:58, loial wrote: Is there a quick way to concatenate all the values in a list into a string, except the first value? I want this to work with variable length lists. All values in list will be strings. Any help appreciated The tutorial covers strings and lists: https://docs.python.org/3/tutorial/introduction.html#strings And there is ample reference documentation for strings and lists: https://docs.python.org/3/library/stdtypes.html#string-methods https://docs.python.org/3/library/string.html https://docs.python.org/3/library/stdtypes.html#sequence-types-list-tuple-range Get to know strings and lists, and this should be a trivial problem to solve. Or just copy/paste the answers others gave and be confused the next time you need to solve a simple problem. -- https://mail.python.org/mailman/listinfo/python-list