Important Notice:

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

9. reverse():-

      इस method का use list में element के order को reverse करने के लिए किया जाता है।

a=[10,20,30]

a.reverse()

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

10. sort():-

      इस method का use list में item को sort करने के लिए किया जाता है। sort के माध्यम लिस्ट को ascending order या descending order में कर सकते हैं।

1. ascending order:

a=[50,20,30,15,65,79,35]

a.sort()

print(a)                                            # [15, 20, 30, 35, 50, 65, 79]

2. descending order:

a=[50,20,30,15,65,79,35]

a.sort(reverse=True)

print(a)                                            # [79, 65, 50, 35, 30, 20, 15]

3. sort Not copy in another variable

a=[50,20,30,15,65,79,35]

b=a.sort()

print(b)                                            # None

 

 

9. reverse():-

This method is used to reverse the order of elements in the list.

a=[10,20,30]

a.reverse()

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

10. sort():-

       This method is used to sort items in the list. Through sort, you can arrange the list in ascending order or descending order.

1. ascending order:

a=[50,20,30,15,65,79,35]

a.sort()

print(a)                                            # [15, 20, 30, 35, 50, 65, 79]

2. descending order:

a=[50,20,30,15,65,79,35]

a.sort(reverse=True)

print(a)                                          # [79, 65, 50, 35, 30, 20, 15]

3. sort Not copy in another variable

a=[50,20,30,15,65,79,35]

b=a.sort()

print(b)                                           # None

 

error: Content is protected !!