About 50 results
Open links in new tab
  1. python - How do I make a flat list out of a list of lists? - Stack Overflow

    If your list of lists comes from a nested list comprehension, the problem can be solved more simply/directly by fixing the comprehension; please see How can I get a flat result from a list …

  2. python - What does list [x::y] do? - Stack Overflow

    Jan 27, 2012 · What does list [x::y] do? [duplicate] Asked 14 years, 1 month ago Modified 8 years, 9 months ago Viewed 121k times

  3. Python: list of lists - Stack Overflow

    First, I strongly recommend that you rename your variable list to something else. list is the name of the built-in list constructor, and you're hiding its normal function. I will rename list to a in the following. …

  4. What is the difference between list [1] and list [1:] in Python?

    Oct 5, 2012 · By using a : colon in the list index, you are asking for a slice, which is always another list. In Python you can assign values to both an individual item in a list, and to a slice of the list.

  5. python - How do I count the occurrences of a list item? - Stack Overflow

    Apr 8, 2010 · 2225 Given a single item, how do I count occurrences of it in a list, in Python? A related but different problem is counting occurrences of each different element in a collection, getting a …

  6. python - Why does += behave unexpectedly on lists? - Stack Overflow

    177 The += operator in python seems to be operating unexpectedly on lists. Can anyone tell me what is going on here?

  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 = Counte...

  8. python - Finding and replacing elements in a list - Stack Overflow

    I have to search through a list and replace all occurrences of one element with another. So far my attempts in code are getting me nowhere, what is the best way to do this? For example, suppose my ...

  9. python - How to convert string representation of list to a list - Stack ...

    275 The json module is a better solution whenever there is a stringified list of dictionaries. The json.loads(your_data) function can be used to convert it to a list.

  10. python - Pythonic way to print list items - Stack Overflow

    I would like to know if there is a better way to print all objects in a Python list than this :