Sequences in Python

Sequences are those types that support Indexing and Slicing. In that respect, strings, unicodes, lists, tuples, buffers and xrange are all sequence types

Indexing allows you to fetch a particular item in the sequence directly

Slicing operation which allows us to retrieve a slice of the sequence i.e. a part of the sequence

For example:

t = 12345, 54321, ‘hello!’

>>> t

(12345, 54321, ‘hello!’)

>>> t[0]

12345

>>> t[:-1]

(12345, 54321)

One thought on “Sequences in Python

Leave a Reply

Your email address will not be published. Required fields are marked *