🌐
GeeksforGeeks
geeksforgeeks.org › python › string-slicing-in-python
String Slicing in Python - GeeksforGeeks
String slicing is a way to get specific parts of a string by using start, end and step values. It’s especially useful for text manipulation. ... Explanation: Here, we used the slice s[0:5] to obtain the substring "Hello" from the original string.
Published: October 7, 2026
🌐
W3Schools
w3schools.com › python › python_strings_slicing.asp
Python - 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.
Discussions

string slicing in python | All possible slicing combination of the string | Slice Operator
Awesome ! didnt know about the stride thing! More on reddit.com
🌐 r/Python
7
92
March 7, 2022
A Comprehensive Guide to Slicing in Python
The start/end indexing when going in reverse has always taken a level of extra mental effort that I don't like. Like excluding the first and last item using [1:-1] is intuitive to me, but doing the same in reverse by doing [-2:0:-1] annoys me (though I do get why its like that). That is why I tend to do [1:-1][::-1] instead. More on reddit.com
🌐 r/Python
40
356
February 1, 2022
Is string slicing actually useful in real world applications?
If you are doing lot of text processing, then yes. Here's an example from my usecase. I have markdown files with code snippets starting with $ or >>> etc. I have to post process those files to extract only the command that comes after the prompt. Easiest solution is string slicing, since the length of the prompt is fixed. Also, slicing in Python can be applied to lists, tuples, strings, etc. So, even if you are not doing text processing, you can apply the knowledge elsewhere. More on reddit.com
🌐 r/learnpython
8
1
October 13, 2020
Help with Tkinter and string slicing please.

You can use the get method of stringvar to get the string you want. For example: print(year.get()) prints the year in the stringvariable.

More on reddit.com
🌐 r/learnpython
8
3
October 4, 2015
🌐
W3Schools
w3schools.com › python › gloss_python_string_slice.asp
Python Slice Strings
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!" print(b[2:5]) Try it Yourself » · Python Strings ...
🌐
Learn By Example
learnbyexample.org › python-string-slicing
Python String Slicing - Learn By Example
April 20, 2020 - # Slice last three characters from the string S = 'ABCDEFGHI' print(S[6:]) # GHI
🌐
Real Python
realpython.com › lessons › string-slicing
String Slicing (Video) – Real Python
So in this case, if our slice was from the beginning, 0, to the end of our string here, 7, and then followed a step of 2, it would start with the very first item, which is 0, and then skip—taking two steps—to grab index 2, and then skip ahead two, and grab index 4, and then go to the end here, index 6. 06:15 For another example, let’s say you used a slice of [1:7:2]. Well, that would start at the second index, 1 instead of 0, and again, take steps of two.
Published: October 1, 2019
🌐
LearnPython.com
learnpython.com › blog › string-slicing-in-python
String Slicing in Python: A Complete Guide | LearnPython.com
April 15, 2024 - In this example, we create the slice using [1:], which includes all the characters from the second one up to the end of the string. We can also use negative index values to slice a string in Python.
🌐
InterServer
interserver.net › home › python › how to slice strings in python: step-by-step tutorial
How to Slice Strings in Python: Step-by-Step Tutorial - Interserver Tips
April 23, 2026 - The step parameter lets you skip characters in a string. It is written as the third value in the slice: [start:stop:step]. For example, if text = "PythonProgramming", you can get every second character using:
🌐
Tutorialspoint
tutorialspoint.com › python › python_slicing_strings.htm
Python Slicing Strings
In this example, we are performing slice operation using default values. var="HELLO PYTHON" print ("var:",var) print ("var[0:5]:", var[0:5]) print ("var[:5]:", var[:5]) ... Similarly, y operand is also optional.
Find elsewhere
🌐
Python Guides
pythonguides.com › slicing-string-in-python
How to Perform String Slicing in Python
September 16, 2025 - I executed the above example code and added the screenshot below. Negative indexing makes it very easy to handle strings when the length may vary. Sometimes, I don’t just want a continuous substring. Instead, I may want every second or third character. This is where the step parameter becomes handy. word = "PythonProgramming" skip_one = word[::2] # Every second character reverse_word = word[::-1] # Reverse the string print(skip_one) print(reverse_word)
🌐
Programming Line
learn.programmingline.com › home › python string slicing
Python String Slicing: Complete Guide
July 18, 2026 - Hello Python Hello Python World! Hello, Python World! Notice that message[0:5] and message[:5] produce the same result — when start is 0 you can simply leave it out. Also notice message[:]: an empty slice copies the entire string.
🌐
Upgrad
upgrad.com › home › tutorials › software & tech › string slicing in python
String Slicing in Python
October 22, 2024 - It uses the [start:end:step] syntax, where: start: The starting index of the slice (inclusive). ... In this example, we achieved the same result as in the previous example, slicing the string text from index 7 to 9 to obtain the substring "is."
🌐
PyTutorial
pytutorial.com › python-string-slicing-explained
PyTutorial | Python String Slicing Explained
2 weeks ago - The first index is 0. Slicing creates a new string from a range of indices. The original string stays the same. You write a slice with square brackets. Inside, use start:stop:step. All three parts are optional. The colon separates them. Python returns a new string.
🌐
CodingNomads
codingnomads.com › string-slicing-in-python
String Slicing in Python
String slicing in Python is when you extract a sub-string from it's parent string. Removing 'age' from 'cottage' is an example of string splicing.
🌐
Upskillcampus
upskillcampus.com › home › slicing strings in python: a step-by-step tutorial
Slicing Strings in Python: A Step-by-Step Tutorial - Latest Insights & Guides | Career Upskilling Blogs
January 2, 2025 - In this example, we’ll slice the string 'DICTIONARY' to get the substring 'CTION'. ... Here, slicing starts at index 2 and ends just before index 7. The character at index 7 ("A") is not included in the result.
🌐
FavTutor
favtutor.com › blogs › python-string-slicing
Python String Slicing with Examples | FavTutor
July 1, 2026 - No. text[1:4] gives the characters at positions 1, 2, and 3. The character at position 4 is left out. Use a negative start with no stop: text[-n:]. For example, "python"[-3:] is "hon".
🌐
AskPython
askpython.com › python › string › slice-strings-in-python
How to Slice Strings in Python? - AskPython
August 6, 2022 - If you want to slice strings in Python, it’s going to be as simple as this one line below. ... Note: All of the above three parameters are optional. By default, start_pos is set to 0, end_pos is considered equal to the length of the string, and step is set to 1. Now let us take some examples to ...
🌐
Unstop
unstop.com › home › blog › string slicing in python | syntax & usage with code examples
String Slicing In Python | Syntax & Usage With Code Examples
February 3, 2025 - The example Python program below ... Programming" #Specifying step 2 helps skip to every other character step_slice = string[0:18:2] print(step_slice)...
🌐
freeCodeCamp
freecodecamp.org › news › slicing-and-indexing-in-python
Slicing and Indexing in Python – Explained with Examples
December 11, 2025 - In these examples, we have used slicing to extract a range of characters from the sentence string. The 4:9 slice means that we are selecting characters starting from index 4 (inclusive) up to index 9 (exclusive), which correspond to the second ...
🌐
Scientech Easy
scientecheasy.com › home › blog › string slicing in python
String Slicing in Python - Scientech Easy
January 26, 2026 - ... # Python program to demonstrate the string slicing using negative index. healthy_juice = 'Orange juice' print('Original string:',healthy_juice) # This statement starts to slice string at position -4 and slices up to position -1 and returns ...
🌐
Hero Vired
herovired.com › learning-hub › topics › string-slicing-in-python
What is String Slicing in Python with Example?
July 26, 2024 - For example, in the string “Python”, ‘-1’ refers to ‘n’, ‘-2’ to ‘o’, and so forth. ... Master cloud architecture, DevOps practices, and automation to build scalable, resilient systems. ... The slice() method creates a slice object, which we can use to specify the start, stop, and step of the slice.