---
title: "How to Understand List and Arrays in Python"
description: "Here are the differences between Lists and Arrays in Python"
url: https://srinimf.com/2021/01/02/python-arrays-vs-lists-best-examples/
date: 2021-01-02
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2021/01/pexels-photo-3978388.jpeg?fit=1880%2C1254&ssl=1
categories: ["Python"]
tags: ["Lists Vs Arrays in Python"]
type: post
lang: en
---

# How to Understand List and Arrays in Python

Lists and Arrays in Python and their differences.

Table of contents

1. [Differences between List and Array](https://srinimf.com/2021/01/02/python-arrays-vs-lists-best-examples/#differences-between-list-and-array)
2. [Working with Lists](https://srinimf.com/2021/01/02/python-arrays-vs-lists-best-examples/#working-with-lists)
   1. [Creating List](https://srinimf.com/2021/01/02/python-arrays-vs-lists-best-examples/#creating-list)
   2. [Appending List](https://srinimf.com/2021/01/02/python-arrays-vs-lists-best-examples/#appending-list)
   3. [List with Heterogeneous data](https://srinimf.com/2021/01/02/python-arrays-vs-lists-best-examples/#list-with-heterogeneous-data)

## **Differences between List and Array**

| S.No. | Python Lists | Python arrays |
| --- | --- | --- |
| 1 | List is mutable. You can change data. | Array is mutable. You can change data |
| 2 | List can have different types of data (it can have **Heterogeneous** data) | Array can have only one type of data |
| 3 | List can have different types of data (it can have **Heterogeneous** data) | Array is an ordered collection of data |
| 4 | List can have different types of data (it can have **Heterogeneous** data) | Array is fixed. It can’t grow and shrink. |

*Python list vs arrays*

## **Working with Lists**

### Creating List

Here’s is logic [how to](https://srinimf.com/2022/10/29/how-to-know-array-dimension-in-python-numpy/) create a List.

```
mylist = [] # empty list is created
mylist.append(1) # append() function is used to add elements into list
mylist.append(2)
mylist.append(3)
print(mylist[0]) # prints 1
print(mylist[1]) # prints 2
print(mylist[2]) # prints 3
# prints out 1,2,3
for x in mylist: # for loop is used
  print(x)
```

[![12 Python Interview Questions](https://i0.wp.com/srinimf.com/wp-content/uploads/2021/01/python-interview-questions.png?resize=600%2C200&ssl=1)](https://srinimf.com/2020/02/23/12-frequently-asked-python-interview-questions/)*12 Python Interview Questions*

### Appending List

Various operation that you can do on Lists.

![Python Code to Create List](https://i0.wp.com/srinimf.com/wp-content/uploads/2021/01/python-list.jpg?resize=662%2C148&ssl=1)*List operations*

Output

![Python List Result](https://i0.wp.com/srinimf.com/wp-content/uploads/2021/01/python-list-result.jpg?resize=669%2C154&ssl=1)*Output*

### List with Heterogeneous data

List supports heterogeneous data.

```
list1 = ['physics', 'chemistry', 2018, 2019]; # It has both numeric and strings
list2 = [1, 2, 3, 4, 5, 6, 7]; # It has only numeric values
print ("list1[0]: ", list1[0])
print ("list2[1:3]: ", list2[1:3])
```

Example:

In the below example you can find both numeric and Strings.

![Python Logic With Different Data-types](https://i0.wp.com/srinimf.com/wp-content/uploads/2021/01/python-list-with-different-data.jpg?resize=669%2C127&ssl=1)*List heterogeneous data*

Output

![Python List Output When it has Different type of data](https://i0.wp.com/srinimf.com/wp-content/uploads/2021/01/python-list-result-of-different-data-types.jpg?resize=672%2C169&ssl=1)*Output*

References

- Here is a [list of operations you can do with a List. ](https://docs.python.org/3/tutorial/datastructures.html#more-on-lists)

Related

- [How to Get Array Dimension in Python [NumPy]](https://srinimf.com/2022/10/29/how-to-know-array-dimension-in-python-numpy/)DateOctober 29, 2022
- [How to Create List in Python Best Example](https://srinimf.com/2018/02/28/python-real-list-commands/)DateFebruary 28, 2018
- [5 Nice Ways to Convert String to Matrix: Python](https://srinimf.com/2024/05/31/5-nice-ways-to-convert-string-to-matrix-python/)DateMay 31, 2024

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2021%2F01%2F02%2Fpython-arrays-vs-lists-best-examples%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2021%2F01%2Fpexels-photo-3978388.jpeg%3Ffit%3D1200%252C800%26ssl%3D1&description=%3Cstrong%3EHow%20to%20Understand%20List%20and%20Arrays%20in%20Python%3C%2Fstrong%3E)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2021/01/02/python-arrays-vs-lists-best-examples/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2021/01/02/python-arrays-vs-lists-best-examples/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2021/01/02/python-arrays-vs-lists-best-examples/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2021/01/02/python-arrays-vs-lists-best-examples/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20%3Cstrong%3EHow%20to%20Understand%20List%20and%20Arrays%20in%20Python%3C%2Fstrong%3E&body=https%3A%2F%2Fsrinimf.com%2F2021%2F01%2F02%2Fpython-arrays-vs-lists-best-examples%2F&share=email)
-

### Like this:

Like Loading…
