# Slicing extracts a range of characters from a string
# Syntax: [start:stop] — start is included, stop is not

name = "RedHorn"
#       R e d H o r n
#       0 1 2 3 4 5 6

# Basic slicing
print(name[0:3])  # Red
print(name[3:7])  # Horn
print(name[0:7])  # RedHorn

# Omit start — Python starts from the beginning
print(name[:3])   # Red

# Omit stop — Python goes to the end
print(name[3:])   # Horn

# Omit both — returns the full string
print(name[:])    # RedHorn

# Slicing with negative indexes
print(name[-4:])   # Horn — last 4 characters
print(name[:-4])   # Red  — everything except last 4

# Slicing never modifies the original string
original = "RedHorn"
piece = original[0:3]

print(original)  # RedHorn — unchanged
print(piece)     # Red

# The full syntax is [start:stop:step]
# step is advanced — you don't need it now
