Introduction & Implementation of List in Python

Lesson 12/20 | Study Time: 10 Min
  • 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 –

    • Brush
    • Leuven
    • 48851964400
    • 3.14
    • Mom

    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:

      • Collection of values
      • Can be of any data type
      • Can be a combination of different types

      Note: The tutor in this video used python console. 

      GDPR

      When you visit any of our websites, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. The information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies. Click on the different category headings to find out more and manage your preferences. Please note, that blocking some types of cookies may impact your experience of the site and the services we are able to offer.