CodeBlessU
learn code with examples

Python List

Introduction

# Example, Python list looks like...
fruits = ["Apple", "Grapes"]

# Example, list holding int and string...
mix_list = [1, "two", "two", 1]
                                 
type(countries)

List is used to store more than one element. Example, list of countries. In Python, list is written with square brackets [ ].

Elements are separated by comma , character. List can hold different data types in same list. List can have duplicate items.


Type

  • class 'list'

Working with List

You can check in details about Creating List. What is Default Value for List variable, Memory requirement for List, How to find length of list.

List Index and List Slice are described in details. List supports various operations like: Replace element, Append at end, Extend at end, Insert at start/front, in middle, at end, Remove element by Value, Remove element by Index, Remove All, Reverse elements, Find occurrences of element in list (or Find if element is present or not), Find index of element.

You can create list of lists.

In this page...

Copyright © All rights reserved.