Python 3.4 - Lists
Lists can store data in different orders and can be used to draw upon data or be used for other purposes.
>>>list_name = [1,1,3,8]
The positions are 0,1,2,3
You can access items in a list:
>>>list_name[2]
3
You can replace players
>>>list_name[2] = 4
>>>List_name
[1,1,4,8]
You can add new items (i.e. +[3,4,5]) to the list but it won't change the list permanently. You can add on things though by .append
. means do this - append
you can remove and add new items (slice) by writing the list name then this [:2]. This will take the first two items in the list and stop at 2. You can do many things to the items once you have sliced them like: adding new items in their place, remove them []
https://www.youtube.com/watch?v=1yUn-ydsgKk
You can print out any item in a list by just specifying the location in the list. You can also create functions that can drop certain items and complete math functions on the rest.
https://www.youtube.com/watch?v=XhXOsgdC9h0
In the process of selecting items in a list you can also modify them (i.e. capitalizing them).
Comments