Research breakthrough possible @S-Logix pro@slogix.in

Office Address

  • 2nd Floor, #7a, High School Road, Secretariat Colony Ambattur, Chennai-600053 (Landmark: SRM School) Tamil Nadu, India
  • pro@slogix.in
  • +91- 81240 01111

Social List

What are the methods of list in python?

Description

To see the major methods of list in python3.

Process

  It add the element in to the list.

Eg:list.append(element).

Insert

  It used to add the new element in a corresponding position.

Eg.list.insert(element index position).

Pop

  It used to delete corresponding index of the object to be removed from the list.

Eg.list.pop(1).

Remove

  This method does not return any value but removes the given object from the list

Eg.list.remove(element).

Reverse

  Its reverse the given element in a list.

Eg.list.reverse().

Sample Code
#Take sample list

list1=[‘sathish’,’sangeetha’,’venkat’,
‘sheela’,’sudhakar’,23,24,25,21,21]

#append the list

print(“**************Append method demo”)

print(“Actual list is\n”,list1)

print(“After append the list”)

list1.append(‘Loganath’)

print(list1)

#insert the list

print(“**************Insert method demo\n”)

print(“After insert the list”)

list1.insert(2,’mano’)

print(list1)

#pop the list

print(“**************Pop method demo\n”)

list1.pop(1)

print(“After pop the list”)

print(list1)

#remove from the list

print(“**************Remove method demo\n”)

list1.remove(‘venkat’)

print(“After remove the list”)

print(list1)

#make reverse of a list

print(“**************Reverse method demo\n”)

list1.reverse()

print(“After reverse the list”)

print(list1)

Screenshots
What are the methods of list in python? add the element in to the list used to delete corresponding index of the object to  be removed from the list delete corresponding index of the object to  be removed from the list reverse the given element in a list