Important Notice:

List in Python

List in Python

4 views 4 min read

List in Python (लिस्ट) :-

List (लिस्ट) Python का एक Built-in Data Type है, जिसका उपयोग एक से अधिक (Multiple) Values को एक ही Variable में Store करने के लिए किया जाता है।

List में समान (Same Type) तथा भिन्न-भिन्न (Different Types) के Data को एक साथ Store किया जा सकता है।

List एक Ordered (क्रमबद्ध), Mutable (परिवर्तनीय) तथा Dynamic (गतिशील) Data Structure है।

Python में List को Square Brackets ([]) के अंदर लिखा जाता है तथा प्रत्येक Element को Comma (,) द्वारा अलग किया जाता है।

          महत्वपूर्ण: List Python में सबसे अधिक उपयोग किए जाने वाले Data Types में से एक है।

Syntax -

list_name = [item1, item2, item3, ...]

Example -

numbers = [10, 20, 30, 40]

print(numbers)
 
Output-
[10, 20, 30, 40]

English

A List is a Built-in Data Type in Python that is used to store multiple values in a single variable.

A List can store same as well as different types of data together.

A List is an ordered, mutable, and dynamic data structure.

In Python, a List is written inside square brackets ([]), and each element is separated by a comma (,).

       Important: A List is one of the most commonly used data types in Python.

Syntax -

list_name = [item1, item2, item3, ...]

Example -

numbers = [10, 20, 30, 40]

print(numbers)
 
Output-
[10, 20, 30, 40]

List की आवश्यकता (Need of List) :-

यदि हमें 5 विद्यार्थियों के नाम Store करने हों, तो बिना List के 5 अलग-अलग Variables बनाने होंगे।

If we want to store the names of five students, we need five separate variables without using a List.

student1 = "Aman"
student2 = "Riya"
student3 = "Rahul"
student4 = "Priya"
student5 = "Neha"
 
लेकिन List का उपयोग करने पर सभी नाम एक ही Variable में Store किए जा सकते हैं।
Using a List, all names can be stored in a single variable.
 
Example -
 
students = ["Aman", "Riya", "Rahul", "Priya", "Neha"]

print(students)
 
Output-
['Aman', 'Riya', 'Rahul', 'Priya', 'Neha']
 
Characteristics of List (लिस्ट की विशेषताएँ) :- 1. Ordered (क्रमबद्ध) -

List एक Ordered (क्रमबद्ध) Data Type है। इसमें Elements उसी क्रम (Order) में Store रहते हैं, जिस क्रम में उन्हें List में जोड़ा जाता है। प्रत्येक Element का एक निश्चित Index Number होता है, जिससे उसे आसानी से Access किया जा सकता है।

English

A List is an ordered data type. The elements are stored in the same order in which they are inserted into the List. Each element has a fixed index number, making it easy to access.

Example-
fruits = ["Apple", "Mango", "Orange"]

print(fruits[0])
print(fruits[1])
print(fruits[2])
 
Output-
Apple
Mango
Orange
 
2. Mutable (परिवर्तनीय) -

List Mutable (परिवर्तनीय) होती है। इसका अर्थ है कि List बनने के बाद भी उसके Elements को बदला (Modify), जोड़ा (Add) या हटाया (Remove) जा सकता है।

English

A List is mutable, which means its elements can be modified, added, or removed even after the List is created.

Example -
fruits = ["Apple", "Mango", "Orange"]

fruits[1] = "Banana"

print(fruits)
 
Output-
['Apple', 'Banana', 'Orange']
 
3. Allows Duplicate Values (डुप्लीकेट मानों की अनुमति) -

List में एक ही Value को एक से अधिक बार Store किया जा सकता है। Python Duplicate Values को हटाता नहीं है, बल्कि उन्हें उसी क्रम में Store करता है।

English

A List allows duplicate values. The same value can appear multiple times in a List.

Example -
numbers = [10, 20, 10, 30, 20]

print(numbers)
 
Output-
[10, 20, 10, 30, 20]
 
4. Stores Different Data Types (विभिन्न प्रकार के डेटा को Store कर सकती है) -

List में अलग-अलग प्रकार (Different Types) के Data जैसे Integer, Float, String, Boolean, List आदि को एक साथ Store किया जा सकता है।

English

A List can store different types of data such as Integer, Float, String, Boolean, and even another List.

Example -
data = [100, 99.5, "Python", True, [1, 2, 3]]

print(data)
 
Output-
[100, 99.5, 'Python', True, [1, 2, 3]]

 

5. Dynamic Size (गतिशील आकार) -

List का आकार (Size) निश्चित नहीं होता। आवश्यकता अनुसार इसमें नए Elements जोड़े या हटाए जा सकते हैं।

English

A List has a dynamic size. Elements can be added or removed whenever required.

Example -
numbers = [10, 20]

numbers.append(30)

print(numbers)
 
Output-
[10, 20, 30]
6. Supports Indexing (इंडेक्सिंग का समर्थन) -

List का प्रत्येक Element 0 से शुरू होने वाले Index Number द्वारा पहचाना जाता है। Index की सहायता से किसी भी Element को सीधे Access किया जा सकता है।

English

Each element in a List has an index number starting from 0. Indexing allows direct access to any element.

Example -
colors = ["Red", "Green", "Blue"]

print(colors[0])
print(colors[2])
 
Output-
Red
Blue

 

7. Supports Negative Indexing (नेगेटिव इंडेक्सिंग का समर्थन) -

List में Negative Indexing भी होती है। इसमें गिनती List के अंतिम Element से शुरू होती है।

  • -1 → अंतिम (Last) Element
  • -2 → अंतिम से दूसरा Element
English

A List also supports negative indexing, where counting starts from the last element.

  • -1 → Last element
  • -2 → Second last element

 Example -

colors = ["Red", "Green", "Blue"]

print(colors[-1])
print(colors[-2])
 
Output-
Blue
Green
8. Supports Slicing (स्लाइसिंग का समर्थन) -

List में Slicing की सहायता से एक साथ कई Elements प्राप्त किए जा सकते हैं।

English

A List supports slicing, which allows retrieving multiple elements at once.

Example -
numbers = [10, 20, 30, 40, 50]

print(numbers[1:4])
 
Output-
[20, 30, 40]

 

9. Can Store Nested Lists (नेस्टेड लिस्ट को Store कर सकती है) -

यदि किसी List के अंदर दूसरी List हो, तो उसे Nested List कहते हैं।

English

A List can contain another List. Such a List is called a Nested List.

Example -
data = [10, 20, [30, 40], 50]

print(data)
print(data[2])
 
Output-
[10, 20, [30, 40], 50]
[30, 40]

 

10. Iterable (इटेरेबल) -

List के प्रत्येक Element पर एक-एक करके for Loop या while Loop की सहायता से कार्य किया जा सकता है।

English

A List is iterable, meaning each element can be accessed one by one using loops such as for or while.

Example -
fruits = ["Apple", "Mango", "Orange"]

for item in fruits:
    print(item)
 
Output-
Apple
Mango
Orange

 

 

Related Notes