The better the data structures of a programming language, the more concentration you can devote to coding a solution to a problem. Python has a bunch of extremely useful data structures.
Lists
A list is quite simply a sequence of objects and the objects don't even have to be the same type. A list is created by listing the items between [ ], while list items are separated by commas.
list = [1, 7, 'bright', 'hub']
print list[2] # returns 'bright'
As with text-manipulation with strings, we can manipulate lists.
print list[1:3] # returns [7, 'bright']
print list[:3] # returns [1, 7, 'bright']
A list's length can be found using the len() function.
print len(list) # returns '4'
Append adds a new item at the end of a list:
list.append('rocks') # will add 'rocks' to our list, and returns [1, 7, 'bright', 'hub', 'rocks']
print len(list) # returns '5'
Elements can be inserted in a list. We pass the position of where we want to insert the element in to the list, followed by the element we want inserted.
list.insert(2, 'hey') # the list now looks like this [1, 7, 'hey', 'bright', 'hub', 'rocks']
We can remove elements either by position or value.
list.remove(2) # removes hey
del list[0] # removes element at the beginning of the list (1)