Creation and use of lists/tuples

--Originally published at Luis Santana's Blog

This two are functions of Python. Starting by defining a list. A List is a list of values, each one is numbered starting from zero, you can modify the values of your list, you can substract them if you want and you can add values.

A tuple is very similar to a list but the main difference is that you can’t change your values, that means that with the values you start are the ones you are going to finish with.

How to create them, a tuple is really easy to create, first of all you give a name to your tuple and then after that you give your values.

And to create a list is exactly the same but you need to use square brackets, not parenthesis. Parenthesis for tuples, square brackets for lists. Here you can see an example:

lists

Here’s a link to some info I found really useful http://sthurlow.com/python/lesson06/

 

giphy1