Next

Creating Lists

  • This lesson teaches how to create lists in Python and store multiple items in a single variable.

  • What is a List? 

    A list in Python is a built-in data structure used to store multiple items in a single variable.

    •  Lists are ordered (items keep their position)

    • Lists are mutable (can be changed)

    • Lists allow duplicate values

    • Lists can store different data types together

    👉 In simple words:
    A list is like a container that holds many values in one place.

    Daily Life Example

    Think of a shopping list 

    Milk
    Bread
    Eggs
    Rice

    All these items are stored in one list.

    Same in Python:

    shopping_list = ["Milk", "Bread", "Eggs", "Rice"]

    print(shopping_list)

    How to Create a List

    Lists are created using square brackets [ ].

List of Numbers

numbers = [10, 20, 30, 40]
print(numbers)

List of Names

students = ["Rahul", "Amit", "Riya", "Neha"]
print(students)

Mixed Data Types

data = ["Radha", 21, True, 55.5]
print(data)

Creating an Empty List

Sometimes we create an empty list and add items later.

items = []
print(items)

Using list() Constructor

Python also provides a built-in function list() to create lists.

fruits = list(("Apple", "Mango", "Banana"))
print(fruits)

Student Marks

A teacher stores marks of one student:

marks = [85, 90, 78, 92, 88]
print(marks)
Next