Be sure to like, share and comment to show your support for our tutorials.
=======================================
Channel - https://goo.gl/pnKLqE
Playlist For This Tutorial - https://goo.gl/EyZFti
Latest Video - https://goo.gl/atWRkF
Facebook - / mastercodeonline
Twitter - https://twitter.com/mastercodeonlin?l...
Website - https://www.tommymyers.codes
======================================
List in Python
In this Python tutorial, we are going to take a tour of list in Python. We will cover the basics of the Python list. List in Python are an ordered list of objects. These objects can be numbers, strings, tuples, dictionaries, other lists and so on. List are an ordered collection object type. Python list are mutable objects that can be changed in place unlike strings.
Features of List in Python
Ordered Collections - List are an object that contains other objects so we can manage them as a group which makes our programs more flexible and efficient. Python list are a sequence which means they maintain a left to right positional ordering just like we saw in strings.
Obtain Objects by Indexing - List are an sequence just like a string so we are able to access objects contained in a list by the index and we call also slice the list like we did with strings.
Mutable Object - List in Python can be changed in place which is referred to as a mutable object type in Python. When use indexing, slicing or concatenation on a list we are actually creating a new list object just like we did in strings. The difference is that Python list contain methods that allow us to grow and shrink our list which makes them mutable. As we move on we will look at all the list methods that we can use to modify list in Python.
Creating List in Python
To create a list in Python we use the square brackets([ ]) with each object contained in the list separated by a comma.
Creating An Empty List in Python
a = []
a
[]
Empty List Explained
a = [] - In this example we create an empty list. A empty list is a list that contains no other objects. Empty list is useful since we can add objects to the list. We assign the empty list a variable of 'a'.
a - We call the empty string object by the variable 'a'. By calling 'a' we will be returned our list object.
[] - We are returned a empty string that contains no objects.
Creating A List In Python
b = ['abc', 123, ['def', 456], {}]
b
['abc', 123, ['def', 456], {}]
b = ['abc', 123, ['def', 456], {}] - We create a list that contains different type of objects. Our objects are strings, numbers, another list and a empty dictionary. Notice our objects are contained in square brackets and comma separated. We assign this list the variable of 'b'.
b - We call our list via the variable of b.
['abc', 123, ['def', 456], {}] - We are returned a list of objects.
Conclusion
In this tutorial we have learned how to create a list in Python. If you have any questions about creating list in Python leave a comment below.
На этой странице сайта вы можете посмотреть видео онлайн How To Create List In Python 3 длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Code master 22 Октябрь 2015, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 22,786 раз и оно понравилось 68 зрителям. Приятного просмотра!