Important Notice:

Course Content
List Manipulation in Python (Chapter-7) M3-R5
About Lesson

7. remove():-

          इस method का use लिस्ट में से किसी element को remove करने के लिए किया जाता है। यदि item list में कई बार आया है तो पहले वाले item को remove किया जाता है।

Syntax:- list.remove(element)

a=[10,20,30]

a.remove(10)

print(a)                                                 # [20, 30]

Note: remove method केवल एक item remove करता है। वह भी पहले वाले item को

a=[10,20,30,10,50,20,60]

a.remove(10)

print(a)                                            # [20, 30, 10, 50, 20, 60]

8. del Statement:-

           del statement का used list से specific items को remove करने के लिए किया जाता है। या slice operator के द्वारा identified किये गए सभी item को remove करने के लिए किया जाता है।

a=[10,20,30]

del a[1]

print(a)                                          # [10, 30]

a=[10,20,30,40,50,30]

del a[1:4]

print(a)                                            # [10, 50, 30]

a=[10,20,30,40,50,30]

del a[:]

print(a)                                            # [ ]

a=[10,20,30,40,50,30]

del a                                                 # deleting list

 

7. remove():-

        This method is used to remove an element from the list. If an item appears multiple times in the list, the first item is removed.

Syntax:- list.remove(element)

a=[10,20,30]

a.remove(10)

print(a)                                           # [20, 30]

Note: remove method removes only one item. That too the previous item

a=[10,20,30,10,50,20,60]

a.remove(10)

print(a)                                              # [20, 30, 10, 50, 20, 60]

8. del Statement:-

        del statement is used to remove specific items from the list. Or it is used to remove all the items identified by the slice operator.

a=[10,20,30]

del a[1]

print(a)                                 # [10, 30]

a=[10,20,30,40,50,30]

del a[1:4]

print(a)                                            # [10, 50, 30]

a=[10,20,30,40,50,30]

del a[:]

print(a)                                                     # [ ]

a=[10,20,30,40,50,30]

del a                                                        # deleting list

error: Content is protected !!