By Hemanta Sundaray on 2021-08-17
Adds the item x to the end of the list.
cloud = ['AWS', 'Heroku','DigitalOcean']
cloud.append("Microsoft Azure")
print(cloud)
# ['AWS', 'Heroku', 'DigitalOcean', 'Microsoft Azure']
Inserts an item at a given position. The first argument i is the index of the element before which to insert the item x, provided as the second argument.
cloud = ['AWS', 'Heroku','DigitalOcean']
cloud.insert(0, "Google Cloud Platform")
print(cloud)
# ['Google Cloud Platform', 'AWS', 'Heroku', 'DigitalOcean']
Removes the first item from the list whose value is equal to x.
cloud = ['AWS', 'Heroku','DigitalOcean']
cloud.remove("Heroku")
print(cloud)
# ['AWS', 'DigitalOcean']
pop() removes and returns the item at the given position (provided as the first argument) in the list.
If no index is specified, pop() removes and returns the last item in the list.
cloud = ['AWS', 'Heroku','DigitalOcean']
popped = cloud.pop(0)
print(cloud)
# ['Heroku', 'DigitalOcean']
print(popped)
# AWS
Removes all items from the list.
cloud = ['AWS', 'Heroku','DigitalOcean']
cloud.clear()
print(cloud)
# []
Returns the number of times x appears in the list.
cloud = ['AWS', 'Heroku','DigitalOcean']
print(cloud.count("AWS"))
# 1
Sorts the items of the list in place.
cloud = ['AWS', 'Heroku','DigitalOcean']
cloud.sort()
print(cloud)
# ['AWS', 'DigitalOcean', 'Heroku']
Reverses the elements of the list in place.
cloud = ['AWS', 'Heroku','DigitalOcean']
cloud.reverse()
print(cloud)
# ['DigitalOcean', 'Heroku', 'AWS']