About 50 results
Open links in new tab
  1. 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 = …

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

    Jan 27, 2012 · What does list [x::y] do? [duplicate] Asked 13 years, 10 months ago Modified 8 years, 6 months ago Viewed 121k times

  3. 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 …

  4. What is :: (double colon) in Python when subscripting sequences?

    Aug 10, 2010 · In Python 3, your example range (N) [::step] produces a range object, not a list. To really see what is happening, you need to coerce the range to a list, np.array, etc.

  5. 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 …

  6. 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 …

  7. Python list error: [::-1] step on [:-1] slice - Stack Overflow

    Jan 3, 2017 · Python's slices seem fairly simple at first, but their behaviour is actually quite complex (notes 3 and 5 are relevant here). If you have a slice a[i:j:k]: If i or j are negative, they …

  8. python - How do I make a flat list out of a list of lists? - Stack …

    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 …

  9. What does the list () function do in Python? - Stack Overflow

    Oct 27, 2014 · In general, one of the nicer things about python is that you don't have to worry about esoteric nuances for built-in types. You'll do better if you just spend time actually using …

  10. Difference between del, remove, and pop on lists in Python

    Related post on similar lines for set data structure - Runtime difference between set.discard and set.remove methods in Python?