About 1,460,000 results
Open links in new tab
  1. String Slicing in Python - GeeksforGeeks

    Apr 9, 2025 · String slicing in Python is a way to get specific parts of a string by using start, end and step values. It’s especially useful for text manipulation and data parsing. Let’s take a quick …

  2. python - Slice a string after a certain phrase? - Stack Overflow

    The simplest answer is a list/string slice combined with a string.find: >>> s = "a descriptor 23 fd" >>> s[:s.find("fd")] 'a descriptor 23 ' >>> s[:s.find("23")] 'a descriptor ' >>> s[:s.find("gggfdf")] # …

  3. How to Index and Slice Strings in Python? - GeeksforGeeks

    Dec 31, 2024 · Slicing Strings in Python. String Slicing allows us to extract a part of the string. We can specify a start index, end index, and step size. The general format for slicing is: string[start …

  4. How to cut a string in Python? - Stack Overflow

    Nov 23, 2011 · take a slice from the string starting at index 0, up to, but not including the index of &in the string.

  5. String Slicing in Python: A Complete Guide - LearnPython.com

    Apr 15, 2024 · To slice a string in Python, we use character indexes. The index of the first character in a string is 0, the second character is 1, and so on. To extract a character from a …

  6. Python Slice Strings - W3Schools

    Slicing Strings. You can return a range of characters by using the slice syntax. Specify the start index and the end index, separated by a colon, to return a part of the string.

  7. How to Perform String Slicing in Python - Python Guides

    Apr 5, 2024 · In Python, two ways exist to extract a substring from the given string. First, you can use the slicing operator, colon ‘:’ inside the square brackets ‘ []’; the second method is the slice …

  8. python - Ways to slice a string? - Stack Overflow

    Jul 31, 2018 · The s[:-3] gives you a string up to, but not including, the comma you want removed ("this is a string") and the s[-2:] gives you another string starting one character beyond that …

  9. Python Slice String: A Beginner's Guide - PyTutorial

    Feb 9, 2025 · To slice a string, you need to specify the start and end indices. The syntax is string[start:end] . The start index is inclusive, and the end index is exclusive.

  10. String Slicing In Python | Syntax, Usage & More (+Code Examples)

    String slicing is a technique that allows you to extract portions of a string in Python (or even the entire string) by specifying a range of indices. With slicing, you can easily grab specific …

  11. Some results have been removed
Refresh