Creating Lists

Lists in Python  are one of the most important and commonly used data structures in Python programming.
A list is used to store multiple values together in a single variable.

Lists help programmers organize, manage, and process collections of data easily.

What is a List in Python

A list is a collection of items stored together inside square brackets.

Lists can store different types of data such as:

  • numbers
  • text
  • decimal values
  • mixed data

Why Lists are Important

Lists are important because they help programmers:

  • store multiple values together
  • organize data efficiently
  • process collections easily
  • reduce the need for multiple variables
  • perform data operations quickly

What Makes a List Special

A List is a collection that is ordered, changeable, and allows duplicates.

  • Square Brackets: We always create lists using [ ].

  • Commas: We separate each item with a ,.

  • Mix & Match: You can put numbers, words (strings), and even True/False (booleans) all in the same list!

Real-World List Examples

Real-Life Example Stored as List
Student Names ["Rahul", "Sneha", "Akhil"]
Marks [90, 80, 70]
Shopping Items ["Milk", "Rice", "Soap"]
Mobile Contacts ["Ravi", "Anu", "David"]
Game Scores [100, 250, 400]

How it Looks (Syntax & Examples)

The Pattern:

list_name = [item1, item2, item3]


Example 1: A List of Strings

fruits = ["apple", "banana", "mango"]
print(fruits)


Output: 

['apple', 'banana', 'mango']



Example 2: A List of Numbers

numbers = [1, 2, 3, 4, 5]
print(numbers)


Output:

[1, 2, 3, 4, 5]

Lists are Mutable

The word:

Mutable

means:

List values can be changed

Example

marks = [10, 20, 30, 40]

marks[0] = 99

print(marks)

Output:

[99, 20, 30, 40]

Advantages of Lists

  • Store multiple values together
  • Easy to modify
  • Supports loops
  • Allows duplicate values
  • Supports mixed data types

Common Beginner Mistakes

Mistake Problem
Using parentheses instead of brackets Wrong data type
Forgetting commas Syntax error
Wrong indexing Index error
Confusing list with string Incorrect output

Summary:

A list in Python is an ordered and mutable collection used to store multiple values together.

Important concepts include:

  • list syntax
  • indexing
  • mutable nature
  • nested lists
  • loops with lists
  • len() function

Lists are widely used in:

  • school management systems
  • gaming applications
  • banking software
  • e-commerce websites

Check your knowledge

Quickly verify what you've learned from this tutorial.

Question 1

Which of the following is a correctly written Python list?

Python uses square brackets [ ] to define a list.

Question 2

What do we use to separate items inside a list?

Every item in a list must be separated by a comma so Python knows where one item ends and the next begins.

Question 3

Can a single Python list store both a word (string) and a number?

Lists are very flexible and can hold a mix of strings, integers, and other types together.

Question 4

What does the term "Mutable" mean in Python?

Mutable means you can add, remove, or change items after the list has been created.

Question 5

What will be the output of print(len(["A", "B", "C"]))?

The len() function counts the number of items; since there are 3 items, the output is 3.

Congratulations!

You've successfully mastered the knowledge check for "Creating Lists."

For more questions and practice, click the link below:

Practice More Questions
Previous Topic Lists Next Topic List Indexing and Slicing