About 499,000 results
Open links in new tab
  1. How do I concatenate two lists in Python? - Stack Overflow

    Do you want to simply append, or do you want to merge the two lists in sorted order? What output do you expect for [1,3,6] and [2,4,5]? Can we assume both sublists are already sorted (as in …

  2. What is the syntax to insert one list into another list in python?

    Sep 20, 2010 · What is the syntax to insert one list into another list in python? [duplicate] Asked 15 years, 2 months ago Modified 6 years, 6 months ago Viewed 351k times

  3. python - Add list to set - Stack Overflow

    Aug 20, 2009 · 254 You can't add a list to a set because lists are mutable, meaning that you can change the contents of the list after adding it to the set. You can however add tuples to the set, …

  4. python - Take the content of a list and append it to another list ...

    Jun 20, 2019 · If you have a list with [0,1,2] and another one with [3,4,5] and you want to merge them, so it becomes [0,1,2,3,4,5], you can either use chaining or extending and should know …

  5. python - Insert an element at a specific index in a list and return …

    Here's the timeit comparison of all the answers with list of 1000 elements on Python 3.9.1 and Python 2.7.16. Answers are listed in the order of performance for both the Python versions.

  6. Append integer to beginning of list in Python - Stack Overflow

    It would be nice for python to add a list.push_front (item) function. This will be obvious and less error-prone.

  7. python - How can I pass a list as a command-line argument with …

    Note: I am collecting multiple string arguments that gets stored in the list - opts.alist If you want list of integers, change the type parameter on parser.add_argument to int

  8. How to append multiple values to a list in Python

    454 I figured out how to append multiple values to a list in Python; I can manually input the values, or put the append operation in a for loop, or the append and extend functions. Any neater …

  9. python - How to concatenate (join) items in a list to a single string ...

    Sep 17, 2012 · For handling a few strings in separate variables, see How do I append one string to another in Python?. For the opposite process - creating a list from a string - see How do I …

  10. python - Adding element to list while iterating - Stack Overflow

    A Python's list is like a dynamic C-Array (or C++ std::vector) under the hood: adding an element might cause a re-allocation of the whole array to fit the new element.