Add Values into Empty List Using For Loop - Python Last Updated : 23 Jul, 2025 Suggest changes Share 1 Likes Like Report Lists are versatile data structures that allow you to store and manipulate collections of items. The simplest way to add values to an empty list is by using append() method. This method adds a single item to the end of the list. Python a = [] # Loop through a range of numbers and add them to the list for i in range(5): a.append(i) # Print the list print(a) Output[0, 1, 2, 3, 4] Other methods that we can use to add values into an empty list using a python for loop are :Table of ContentUsing List ComprehensionUsing extend() inside a For LoopUsing += OperatorUsing a While LoopUsing insert() inside a For LoopUsing List ComprehensionList comprehension is a more compact way to create and add values to a list in one step. This method is concise and often preferred for its readability and efficiency. Python a = [i for i in range(5)] # Print the list print(a) Output[0, 1, 2, 3, 4] Using extend() inside a For LoopAnother method to add values is by using extend() method. This method is used to add multiple values at once to a list. Python a = [] # Create another list of values values = [0, 1, 2, 3, 4] # Use extend to add all values to a a.extend(values) # Print the list print(a) Output[0, 1, 2, 3, 4] Using += OperatorThe += operator allows us to add items from one list to another. This can be useful when you want to add multiple values. Python a = [] # Add values using the += operator a += [0, 1, 2, 3, 4] # Print the list print(a) Output[0, 1, 2, 3, 4] Using a While LoopWe can also use a while loop to add values to a list. This method gives us more control over the loop but is a bit more complex. Python # Create an empty list a = [] # Initialize the counter i = 0 # Use a while loop to add values while i < 5: a.append(i) i += 1 # Print the list print(a) Output[0, 1, 2, 3, 4] Using insert() inside a For LoopThe insert() method allows us to add values to a specific position in the list. While it is not as commonly used to append values at the end of the list, it can still be useful when we want to control where the values are placed. Python a = [] # Loop through a range of numbers and insert them at the beginning for i in range(5): a.insert(0, i) # Print the list print(a) Output[4, 3, 2, 1, 0] H harshasi1eet Follow 1 Article Tags : Python Python Programs python-list Explore Python FundamentalsPython Introduction 2 min read Input and Output in Python 4 min read Python Variables 5 min read Python Operators 4 min read Python Keywords 2 min read Python Data Types 8 min read Conditional Statements in Python 3 min read Loops in Python - For, While and Nested Loops 5 min read Python Functions 5 min read Recursion in Python 4 min read Python Lambda Functions 5 min read Python Data StructuresPython String 5 min read Python Lists 4 min read Python Tuples 4 min read Python Dictionary 3 min read Python Sets 6 min read Python Arrays 7 min read List Comprehension in Python 4 min read Advanced PythonPython OOP Concepts 11 min read Python Exception Handling 5 min read File Handling in Python 4 min read Python Database Tutorial 4 min read Python MongoDB Tutorial 2 min read Python MySQL 9 min read Python Packages 10 min read Python Modules 7 min read Python DSA Libraries 15 min read List of Python GUI Library and Packages 3 min read Data Science with PythonNumPy Tutorial - Python Library 3 min read Pandas Tutorial 4 min read Matplotlib Tutorial 5 min read Python Seaborn Tutorial 15+ min read StatsModel Library- Tutorial 4 min read Learning Model Building in Scikit-learn 8 min read TensorFlow Tutorial 2 min read PyTorch Tutorial 6 min read Web Development with PythonFlask Tutorial 8 min read Django Tutorial | Learn Django Framework 7 min read Django ORM - Inserting, Updating & Deleting Data 4 min read Templating With Jinja2 in Flask 6 min read Django Templates 7 min read Python | Build a REST API using Flask 3 min read How to Create a basic API using Django Rest Framework ? 4 min read Python PracticePython Quiz 1 min read Python Coding Practice 1 min read Python Interview Questions and Answers 15+ min read My Profile ${profileImgHtml} My Profile Edit Profile My Courses Join Community Transactions Logout Like