Python Tutorial

Introduction

Edit Template

Python Tutorial

Introduction

Edit Template

Python Lists

In Python, a list is like a smart container that can hold many items at once — numbers, text, or even a mix of both. Lists are:

  • Ordered: Items stay in the same sequence you put them.

  • Changeable: You can update, add, or remove items after the list is created.

  • Enclosed in square brackets: Use [] and separate items with commas.

Example 1:

				
					numbers = [4, 7, 7, 1, 3, 9]
colors = ["Orange", "Purple", "Teal"]

print(numbers)
print(colors)

				
			

Output:

				
					[4, 7, 7, 1, 3, 9]
['Orange', 'Purple', 'Teal']

				
			

You can repeat values, and Python will store them exactly as given.

Example 2:

A single list can hold different types of values — strings, numbers, floats, or even booleans.

				
					student_info = ["Areeba", 20, "BS Computer Science", 3.65]
print(student_info)

				
			

Output:

				
					['Areeba', 20, 'BS Computer Science', 3.65]


				
			

Why Lists Are Useful?

Think of a list like a backpack. You can put:

  • Books (strings),

  • Water bottle (float),

  • ID card (number),

  • And still add more things later!

Lists are essential for managing related data — especially when you want to loop, sort, or filter information.

Scroll to Top