About 1,160,000 results
Open links in new tab
  1. python - : splice keeps cutting off the third+ digit. Why? How do I …

    2 days ago · So I have an assignment that I am working on in python, where I can only splice using the : splice method (i.e group= strg [:index]). For some reason splice refuses to see anything past 2 digits when its numbers. Words are fine but digits are being clipped. here is …

  2. 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.

  3. How to slice a list from an element n to the end in python?

    Return a slice of the list after a starting value: my_list = ['a','b','c','d'] start_from = 'b' # value you want to start with slice = my_list[my_list.index(start_from):] # returns slice from starting value to end

    Missing:

    • Splice

    Must include:

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

    Dec 8, 2022 · For example, if you want to slice an array from the first value to the third, here's how: import array as arr numbers = arr.array( 'i' , [ 1 , 2 , 3 , 4 , 5 ]) copy = numbers[: 3 ] print(copy) # array('i', [1, 2, 3])

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

    The third rule of slice assignment is, the assigned list (iterable) doesn't have to have the same length; the indexed slice is simply sliced out and replaced en masse by whatever is being assigned: >>> p = ['P','y','t','h','o','n'] # Start over >>> p[2:4] = ['s','p','a','m'] >>> p ['P','y','s','p','a','m','o','n']

  6. Python - Slicing Strings - W3Schools

    Specify the start index and the end index, separated by a colon, to return a part of the string. Get the characters from position 2 to position 5 (not included): b = "Hello, World!" Note: The first character has index 0. By leaving out the start index, the range will start at the first character:

  7. A Quick Guide to Slicing in Python – Become a Python Ninja

    Slicing has incredibly simple syntax; after a sequence type variable inside square brackets you define a start point, an end point and a step, separated by colons like so; var [start:end:step]. However it doesn’t work the way you might first assume it to.

  8. Python List Slicing: How to Use It [With Simple Examples]

    Oct 29, 2023 · With Python’s list slicing notation you can select a subset of a list, for example, the beginning of a list up to a specific element or the end of a list starting from a given element. The slicing notation allows specifying the start index, stop index, and …

  9. Advanced slicing rules? - Python Help - Discussions on Python.org

    Aug 14, 2022 · One easy way to think of slicing is that the positions are between the items. So your list_a = [1, 2, 3] might be labelled with positions like this: We can use negative indices to label all positions except the final one:

  10. python - How do I slice a string every 3 indices? - Stack Overflow

    May 12, 2011 · I'm using Python to program for the lab I work at. How can I slice out every 3 characters in a given string and append it to a list? i.e. XXXxxxXXXxxxXXXxxxXXXxxxXXX (where X or x is any given letter) string = 'XXXxxxXXXxxxXXXxxxXXXxxxXXX' mylist = [] for x in string: string[?:?:?] mylist.append(string)

  11. Some results have been removed
Refresh