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

    Python >= 3.5 alternative: [*l1, *l2] Another alternative has been introduced via the acceptance of PEP 448 which deserves mentioning. The PEP, titled Additional Unpacking Generalizations, …

  2. slice - How slicing in Python works - Stack Overflow

    Python slicing is a computationally fast way to methodically access parts of your data. In my opinion, to be even an intermediate Python programmer, it's one aspect of the language that it …

  3. list - In Python, what is the difference between ".append ()" and ...

    In general, if you're appending/extended an existing list, and you want to keep the reference to the same list (instead of making a new one), it's best to be explicit and stick with the append …

  4. python - How do I clone a list so that it doesn't change …

    4147 new_list = my_list doesn't actually create a second list. The assignment just copies the reference to the list, not the actual list, so both new_list and my_list refer to the same list after …

  5. python - Find a value in a list - Stack Overflow

    In Python 3, filter doesn't return a list, but a generator-like object. Finding the first occurrence If you only want the first thing that matches a condition (but you don't know what it is yet), it's …

  6. How to list all installed packages and their versions in Python?

    Is there a way in Python to list all installed packages and their versions? I know I can go inside python/Lib/site-packages and see what files and directories exist, but I find this very awkward. ...

  7. Meaning of list[-1] in Python - Stack Overflow

    I have a piece of code here that is supposed to return the least common element in a list of elements, ordered by commonality: def getSingle(arr): from collections import Counter c = …

  8. python - List attributes of an object - Stack Overflow

    dir () is exactly what I was looking for when I Googled 'Python object list attributes' -- A way to inspect an instance of an unfamiliar object and find out what it's like.

  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 - How can I pass a list as a command-line argument with …

    Don't use quotes on the command line 1 Don't use type=list, as it will return a list of lists This happens because under the hood argparse uses the value of type to coerce each individual …