🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to Python Notes
Topic #18

Slicing Strings


Slicing

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.

Example

b = "Hello, World!"
  print(b[2:5])

Note: The first character has index 0.


Slice From the Start

By leaving out the start index, the range will start at the first character:

Example

b = "Hello, World!"
  print(b[:5])

Slice To the End

By leaving out the end index, the range will go to the end:

Example

b = "Hello, World!"
  print(b[2:])

Negative Indexing

Example

b = "Hello, World!"
  print(b[-5:-2])

Want to go beyond the notes?

Join CodingNow 2.0's Python course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Slicing Strings – FAQs

Quick answers about learning Slicing Strings in Python.

This free note from CodingNow 2.0 explains Slicing Strings in Python — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Python topic on CodingNow 2.0, including Slicing Strings, is 100% free with no signup required.
With focused practice, most students grasp Slicing Strings in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now