negatives count back from the right end (offset - is the last itemeither kind of offset can be used to give positions in indexing and slicing operations the last line in the preceding example demonstrates slicinga generalized form of indexing that returns an entire sectionnot single item probably the best way to think of slicing is that it is type of parsing (analyzing structure)especially when applied to strings--it allows us to extract an entire section (substringin single step slices can be used to extract columns of datachop off leading and trailing textand more in factwe'll explore slicing in the context of text parsing later in this the basics of slicing are straightforward when you index sequence object such as string on pair of offsets separated by colonpython returns new object containing the contiguous section identified by the offset pair the left offset is taken to be the lower bound (inclusive)and the right is the upper bound (noninclusivethat ispython fetches all items from the lower bound up to but not including the upper boundand returns new object containing the fetched items if omittedthe left and right bounds default to and the length of the object you are slicingrespectively for instancein the example we just saws[ : extracts the items at offsets and it grabs the second and third itemsand stops before the fourth item at offset nexts[ :gets all items beyond the first--the upper boundwhich is not specifieddefaults to the length of the string finallys[:- fetches all but the last item--the lower bound defaults to and - refers to the last itemnoninclusive this may seem confusing at first glancebut indexing and slicing are simple and powerful tools to useonce you get the knack rememberif you're unsure about the effects of slicetry it out interactively in the next you'll see that it' even possible to change an entire section of another object in one step by assigning to slice (though not for immutables like stringshere' summary of the details for referenceindexing ( [ ]fetches components at offsetsthe first item is at offset negative indexes mean to count backward from the end or right [ fetches the first item [- fetches the second item from the end (like [len( )- ] string fundamentals