Python

LIST in python

LIST

  • List is an ordered sequence of items.
  • It is one of the most used data type in python and is very flexible.
  • All the items in list do not need to be of same type.
  • List is one of 4 built-in data types in Python used for collection of data, the other 3 are Tuple , set and Dictionary.
  • List is created using square brackets.

Example:1

nums=[12,34,56,78,89,12]
print(nums)

output: [12, 34, 56, 78, 89, 12]

Items in a list

  • Items in a list are changeableordered  and allow duplicate values.
  • List items are indexed, starting from [0] index value.

Ordered

  • Here the term ordered refers that, it means the items have a defined order, and this order cannot be changed.
  • If  in case any new items are added to the list that will be placed at the end of the list.

Changeable

  • Here the term changeable indicates that the values in a list can be removed, added or changed after the creation of list.

Allow Duplicates

In a list  it allows us to  have the  repeated values

Example2

>> lst=[12, 34, 45, 67, 89,12]

>>print(lst)

Indexing in list

  • In list indexing is as in string i.e., left to right for reversal printing then indexing is done from right to left.
  • If you want to pick up the third value that is second indexed value then

Example:

Lakshmi Durga

Share
Published by
Lakshmi Durga

Recent Posts

Google Spam Update 2025: Impact, Recovery Guide & SpamBrain Explained

Google released a spam update on 26th of August 2025 and this is affecting a…

1 month ago

Google Experiments with Black Sitelink Colors instead of Blue

Google keeps on testing google search display all the time and this time we are…

1 year ago

What are Template Tags in WordPress? How to Use Template Tags

In wordpress if you are developing new or custom wordpress theme or wordpress plugin then…

2 years ago

Google Search Indexing Issues Started on 31st January to February 2024

If you are experiencing indexing issues of your website then you are not alone and…

2 years ago

Create QR Code for Pages & Post using Plugin in WordPress

On your wordpress website if you want to generate qr code for pages and posts…

2 years ago

Add Google Search Console HTML File Upload on WordPress

If you are trying to verify your WordPress website with google search console with html…

2 years ago