What are the differences between these built-in Python data types: list, sequence and slice? As I see it, all three essentially represent what C++ and Java call array.
What are the differences between these built-in Python data types: list , sequence and
Share
listare more than plain arrays. You can initialize them without giving the number of items. You canappend/pushto them, you canremove/pop/delitems from them, you can have lists of different types of objects (e.g.,[1,'e', [3]]), you can have recursive lists… and you can slice lists, which means getting a new list with only a few of the items.sliceare an object type used “behind the scenes” to handle extended slicing in thea[start:stop:step]form, ashelp(slice)reveals.“Sequence” is not an object, more like an informal interface some objects like
listimplement.