What´s list?

--Originally published at 101 For Tec

Today I´m talking about lists, as I mention in a previous post, a list is a group of items that have a position. The syntax of the lists is like it follows:

name_of_the_list = [elements,elements]

The positions start at 0 and you call them like this

name_of_the_list [0]

Also you can modify them just calling the position and making it equal to the new value

list1[0]:  physics

or delete elements writing del before the position

del list1[2];

Also you´re able to do the basic operations

Python Expression Results Description
len([1, 2, 3]) 3 Length
[1, 2, 3] + [4, 5, 6] [1, 2, 3, 4, 5, 6] Concatenation
[‘Hi!’] * 4 [‘Hi!’, ‘Hi!’, ‘Hi!’, ‘Hi!’] Repetition
3 in [1, 2, 3] True Membership
for x in [1, 2, 3]: print x, 1 2 3 Iteration

or for more fun stuff check this:

https://www.tutorialspoint.com/python/python_lists.htm