Skip to content

vshabbir/Python-Slicing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Here’s a clean README.md draft for your GitHub repo:

# Python-Slicing 🔪🐍

Ever wondered how Python slicing works?  
What does it actually do in the background?  

This project provides a simple source code implementation that explains how slicing is done.  
The output is exactly similar to Python’s built-in slicing — but written manually to help understand the logic behind it.

---

## 🚀 How to Use

import slicer

# parameters: start, stop, step (optional)

print(slicer.slice_string(1, 3))      # string[1:3]
print(slicer.slice_string(1, 3, -1))  # string[1:3:-1]
print(slicer.slice_string(1, 3, 1))   # string[1:3:1]

If you don’t want to define the start or stop index, just pass an empty string '':

slicer.slice_string(1, '')     # string[1:]
slicer.slice_string('', '')    # string[:]
slicer.slice_string('', 3)     # string[:3]

📖 Examples

Call Equivalent Python Slice Output (with default string "abcdefghijklmnopqrstuvwxyz")
slice_string(1, 3) string[1:3] "bc"
slice_string('', '') string[:] "abcdefghijklmnopqrstuvwxyz"
slice_string(-1, '') string[-1:] "z"

⚠️ Note

  • This is not a replacement for Python slicing.
  • The goal is to help you analyze different slicing scenarios and answer the question: "What exactly happens when I slice a string in Python?"
  • Perfect for learning, experimenting, and debugging slicing logic.

📂 Project Structure

slicer.py    # core implementation
README.md    # documentation

About

Ever wondered how python slicing works? What does it do in the background? This simple source code explains how it's done. The output is exactly similar to python slicing.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages