Friday, June 19, 2020

list methods in python


bikes =["honda","yamaha","hero","bugati","royalenfield"]

print("bikes[0]",bikes[0])
print("bikes[1]",bikes[1])
print("bikes[2]",bikes[2])
print("bikes[3]",bikes[3])
print("bikes[4]",bikes[4])
print(bikes)
bikes.append("sports")
print(bikes)
bikes.append("bajaj")
print(bikes)
#syntax
#bikes.insert(index,data)
bikes.insert(0, "mini")
print(bikes)
bikes.insert(10, "pulsar")
print(bikes[8])

bikes.remove("hero")
print(bikes)
bikes.remove("royalenfield")
print(bikes)
bikes.pop()
print(bikes)
bikes.pop()
print(bikes)
bikes.pop()
print(bikes)
print(bikes)
bikes.sort()
print(bikes)
bikes.reverse()
print(bikes)

python class topic video