Python List Methods in Hindi | Python Programming in Hindi

Python List Methods in Hindi In Python Programming

Python Programming In Hindi me aaj hum Python list methods ke baare me baat karenge. Python ek powerful programming language hai jismein list methods ka use karke hum apni lists ko asaani se modify kar sakte hain. Lists ek ordered collection of items hoti hain jo kisi bhi type ke data ko store kar sakti hain. Aaiye, kuch important list methods ke baare me detail me jaanate hain jo aapko Python Programming In Hindi sikhne me madadgar sabit honge.

Python List Methods in Hindi | Python Programming in Hindi
Python List Methods in Hindi | Python Programming in Hindi

Python List Methods In Hindi

1. Python append()

append() method ka use list me new element add karne ke liye hota hai. Yeh method element ko list ke last me insert karta hai.

यह भी पढ़ें: 250+ Free Python Projects with Source Code: From Beginner to Advanced

Example:

l = ['Banana', 'Papaya']
print('Before add:', l)
l.append('Grapes')
l.append('Mango')
print('After add:', l)

Output:

Before add: ['Banana', 'Papaya']
After add: ['Banana', 'Papaya', 'Grapes', 'Mango']

2. Python clear()

clear() method list ko puri tarah se clear kar deta hai, yani list se saare elements ko remove kar deta hai.

Example:

l = ['Banana', 'Papaya']
print('Before clear:', l)
l.clear()
print('After clear:', l)

Output:

Before clear: ['Banana', 'Papaya']
After clear: []

3. Python copy()

copy() method list ki ek copy return karta hai. Yeh shallow copy hoti hai, yani nayi list ka data purani list ke data se linked nahi hota.

Example:

l1 = ['Banana', 'Papaya']
l2 = l1.copy()
l1.append('Mango')
l1.append('Grapes')
print('list l1:', l1)
print('list l2:', l2)

Output:

list l1: ['Banana', 'Papaya', 'Mango', 'Grapes']
list l2: ['Banana', 'Papaya']

4. Python insert()

insert() method bhi list me new element add karta hai, lekin yeh specified index par element ko insert karta hai. Agar us index par pehle se koi element hai, toh usse shift kar deta hai.

Example:

l = ['Papaya', 'Mango']
print('Before insert:', l)
l.insert(0, 'Grapes')
l.insert(2, 'Apple')
print('After insert:', l)

Output:

Before insert: ['Papaya', 'Mango']
After insert: ['Grapes', 'Papaya', 'Apple', 'Mango']

5. Python pop()

pop() method list se item remove karta hai. By default yeh last item remove karta hai, lekin agar index number pass karein toh us particular index se item remove karta hai.

Example:

l = ['Papaya', 'Mango', 'Grapes']
print('Before remove:', l)
l.pop()
l.pop(0)
print('After remove:', l)

Output:

Before remove: ['Papaya', 'Mango', 'Grapes']
After remove: ['Mango']

6. Python remove()

remove() method first occurrence of specified value ko remove karta hai. Agar specified value list me nahi hai toh ValueError raise karta hai.

Example:

l = ['Papaya', 'Mango', 'Grapes', 'Mango']
print('Before remove:', l)
l.remove('Mango')
print('After remove:', l)

Output:

Before remove: ['Papaya', 'Mango', 'Grapes', 'Mango']
After remove: ['Papaya', 'Grapes', 'Mango']

7. Python reverse()

reverse() method list ke elements ko reverse order me kar deta hai.

Example:

l = ['Papaya', 'Apple', 'Mango']
print('Before reverse:', l)
l.reverse()
print('After reverse:', l)

Output:

Before reverse: ['Papaya', 'Apple', 'Mango']
After reverse: ['Mango', 'Apple', 'Papaya']

8. Python sort()

sort() method list ko sort karta hai. Sorting karte waqt list me same type ke items hone chahiye.

Example:

l = ['Papaya', 'Apple', 'Mango']
print('Before sort:', l)
l.sort()
print('After sort:', l)

Output:

Before sort: ['Papaya', 'Apple', 'Mango']
After sort: ['Apple', 'Mango', 'Papaya']

9. Python count()

count() method list me specified element ki occurrences ko count karta hai.

Example:

l = ['Papaya', 'Mango', 'Grapes', 'Mango']
print('Count of Mango:', l.count('Mango'))

Output:

Count of Mango: 2

10. Python extend()

extend() method ek list ke elements ko dusri list me add karta hai.

Example:

l1 = ['Papaya', 'Mango']
l2 = ['Grapes', 'Apple']
print('Before extend:', l1)
l1.extend(l2)
print('After extend:', l1)

Output:

Before extend: ['Papaya', 'Mango']
After extend: ['Papaya', 'Mango', 'Grapes', 'Apple']

11. Python index()

index() method specified element ka first occurrence index return karta hai.

Example:

l = ['Papaya', 'Mango', 'Grapes', 'Apple']
print('Index of Mango:', l.index('Mango'))

Output:

Index of Mango: 1

Python Programming In Hindi

Python Programming me list methods ka use karke aap apne data ko efficiently manage kar sakte hain. Yeh methods aapko data ko manipulate karne ki flexibility dete hain, jo Python ko ek powerful aur versatile language banata hai. Agar aap Python Programming In Hindi sikh rahe hain, toh in list methods ka achhe se samajhna aur practice karna zaroori hai.

Python Programming In Hindi Me List Methods Ke Fayde

Efficiency: Lists methods ka use karke aap apne code ko concise aur readable bana sakte hain.

Flexibility: Yeh methods aapko data ko manipulate karne ki flexibility dete hain bina kisi complex code ke.

Simplicity: Python list methods ka syntax simple aur easy to understand hota hai, jo beginners ke liye ideal hai.

Python Programming In Hindi sikhne me yeh list methods aapko kaafi madad karenge. Yeh methods aapke data handling ko aur bhi aasaan aur effective bana dete hain. Python ki simplicity aur readability ke wajah se yeh programming language beginners ke liye bhi kaafi accessible hai.

Conclusion

Python list methods ka use karte hue apne code ko efficient aur readable banana bahut hi asaan hai. Agar aap Python Programming In Hindi seekh rahe hain, toh yeh methods aapke liye bahut hi helpful honge. Aasha karte hain ki yeh article aapko Python list methods ko achhe se samajhne me madad karega aur aapke programming skills ko next level tak le jaayega.

Python Programming ek aesi skill hai jo aapko multiple domains me opportunities provide kar sakti hai. Chahe aap data science me interested ho, web development ya software development me, Python list methods aapke workflow ko streamline karne me madad karenge. Toh bina kisi deri ke, in list methods ko practice karna shuru kijiye aur Python Programming In Hindi ko aur bhi enjoy kijiye!

यह भी पढ़ें: Python Programming In Hindi | Python Tutorials In Hindi

और नया पुराने

संपर्क फ़ॉर्म