[BangPypers] lists and tuples

Siva Ranganath workforsiva at gmail.com
Wed Oct 5 05:18:20 EDT 2016

Thanks for quick reply.
Thanks Noufal ibrahim.

On Tue, Oct 4, 2016 at 5:41 PM, Noufal Ibrahim <noufal at nibrahim.net.in>

> On , Siva Ranganath wrote:
>> Hi All,
>> please let me know few cases when we will go with Lists and tuples in
>> pyhton.
> Lists are like vectors (since you're from a C++ background). They can
> expand/contract depending on data and are also heterogeneous meaning that
> all the elements needn't be of the same type. It's a flexible container for
> holding things. Lists are often iterated over (e.g. for i in all_documents)
> or indexed (e.g. students[5] to get the fifth student).
> Tuples are more like C structures in that they're used to hold a few
> related things together. They have several behaviours similar to a list
> (can be indexed, iterated over etc.) but are not mutable (you can't
> add/remove elements from them). However, they're often used differently.
> They're used as C structs but without names for the fields. So, points in
> 2D space (x,y) are a good candidate for a tuple or maybe a colour in RGB
> colourspace denoted by (r,g,b).
> For a more in depth discussion, you should look at the official python
> tutorial at https://docs.python.org/3.6/tutorial/
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> https://mail.python.org/mailman/listinfo/bangpypers

More information about the BangPypers mailing list