As the name suggests, List is an ordered sequence of data. In real life, if you could make a list of things that come to your mind (or event for any specific purpose), it could be something like this –
Well, this is my list. You could make your own list & include whatever you want in it. So, in my list, I have included what I do early in the morning, my city, my mobile number, the value of pi to two digits, and mom. It has different types of data – strings, float, and integers
Well, this is the kind of flexibility Python List provides. It can hold elements of different data types. Declaring a List is fairly straightforward. You use square brackets ([]) and separate the items by a comma. Let me write an example -
A = ["Brush", "Leuven", 48851964400, 3.14, "Mom"]
Lists are mutable. Say if you want to change some item on a List, you can do that. For example, if I don’t like ‘Brush’’, and want to replace this with ‘Morning Walk’, I can do it –
A = ["Morning Walk", "Leuven", 48851964400, 3.14, "Mom"]
Some essential features of Python lists are:
Note: The tutor in this video used python console.