---
title: "How to create list in python?Give suitable example."  
description: "How to create list in python?Give suitable example."  
author: "Amrita Bhattacharjee"  
published: 2023-03-28  
updated: 2023-04-20  
canonical: https://www.mindstick.com/forum/157620/how-to-create-list-in-python-give-suitable-example  
category: "python"  
tags: ["python"]  
reading_time: 2 minutes  

---

# How to create list in python?Give suitable example.

How to create list in [python](https://www.mindstick.com/articles/75378/simple-yet-useful-tips-when-using-python)?Give suitable example.

## Replies

### Reply by Aryan Kumar

In Python, you can create a list by enclosing a comma-separated sequence of items in square brackets **[]**.

Here's an example of creating a list of numbers:

```python
my_list = [1, 2, 3, 4, 5]
```

You can also create an empty list and add items to it later using square bracket notation **[]**:

```python
my_list = []
my_list.append(1)
my_list.append(2)
my_list.append(3)
```

You can also use the **list()** constructor to create a list from a sequence, such as a string or a tuple:

```python
my_string = 'hello'
my_list = list(my_string)
```

Once you have created a list, you can access its items by using square bracket notation to specify the index:

```python
item = my_list[0]
print(item)  # Output: 1
```

### Reply by Krishnapriya Rajeev

The list is one of the 4 built-in data types in Python, which is used to store multiple items in a single variable. Items in lists are ordered, mutable, and allow for duplicate values.

Example:

```plaintext
list1 = ["Delhi","Kolkata","Mumbai"]
```

Lists can also contain items of different data types.

```plaintext
list2 = ["Apple", False, 73, "chair", 12.47]
```

We can insert a new list item by using the insert() method.

```plaintext
list1.insert(2, "Chennai")
# Output = ['Delhi', 'Kolkata', 'Chennai', 'Mumbai']
```

To add items to the end of the list, we use append().

```plaintext
list1.append("Agra")
# Output = ['Delhi', 'Kolkata', 'Chennai', 'Mumbai', 'Agra']
```

Lists are indexed, hence the items can be accessed by using an index number.

```plaintext
print(list1[1])
# Output = Kolkata
```


---

Original Source: https://www.mindstick.com/forum/157620/how-to-create-list-in-python-give-suitable-example

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
