About 110,000 results
Open links in new tab
  1. python - How to split an integer into a list of digits ... - Stack Overflow

    Dec 15, 2009 · While list(map(int, str(x))) is the Pythonic approach, you can formulate logic to derive digits without any type conversion: n = int(log10(x)) for i in range(n, -1, -1): factor = 10**i. k = x // factor. yield k. x -= k * factor. One benefit of a generator is you can feed seamlessly to set, tuple, next, etc, without any additional logic.

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

    Explain Python's slice notation. In short, the colons (:) in subscript notation (subscriptable[subscriptarg]) make slice notation, which has the optional arguments start, stop, and step: sliceable[start:stop:step] Python slicing is a computationally fast way to methodically access parts of your data.

  3. Python slice() Function - W3Schools

    The slice() function returns a slice object. A slice object is used to specify how to slice a sequence. You can specify where to start the slicing, and where to end. You can also specify the step, which allows you to e.g. slice only every other item.

  4. Python List Slicing - GeeksforGeeks

    Mar 8, 2025 · Python list slicing is fundamental concept that let us easily access specific elements in a list. In this article, we’ll learn the syntax and how to use both positive and negative indexing for slicing with examples.

  5. Slicing and Indexing in Python – Explained with Examples

    Mar 29, 2023 · Slicing and indexing are two fundamental concepts in Python. They help you access specific elements in a sequence, such as a list, tuple or string. By using these techniques, you can extract substrings from strings, filter lists, and …

  6. Python Slicing – How to Slice an Array and What Does [::-1] Mean?

    Dec 8, 2022 · In this article, we've briefly looked at how to declare arrays in Python, how to access values in an array, and also how to cut – or slice – a part of an array using a colon and square brackets. We also learned how slicing works …

  7. How to Slice Lists/Arrays and Tuples in Python

    A guide to slicing Python lists/arrays and Tuples, using multiple forms of syntax. We can use the short form of Python slicing, or the slice method.

  8. Python slice() function - GeeksforGeeks

    May 9, 2023 · In this article, we will learn about the Python slice () function with the help of multiple examples. Example. Output: World. A sequence of objects of any type (string, bytes, tuple, list, or range) or the object which implements __getitem__ () and __len__ () method then this object can be sliced using slice () method.

  9. Python slice() - Programiz

    The slice() function returns a slice object. In this tutorial, we will learn to use Python slice() function in detail with the help of examples.

  10. Python Slicing | Python slice() Constructor - Python Geeks

    Learn what is Python Slicing, slice constructor & its use cases. See how to use negative indexing to get objects in reverse.

  11. Some results have been removed