bicycles = ['trek','cannondale','redline','specialized']
print(bicycles)
print(bicycles[1])
print(bicycles[1].title())#title()让第一个字母变大写
print(bicycles[-2])#python将索引改为负号可以变为倒数第几个
bicycles.append('ducati')#在结尾添加元素
print(bicycles)
bicycles.insert(1,'one')#在任意位置插入元素
print(bicycles)
del bicycles[1]#删除一个位置的元素
print(bicycles)
#有时候你需要删除元素并获取值
poped = bicycles.pop()
print(poped)
print(bicycles)
poped = bicycles.pop(-1)#指定索引也可进行删除
print(bicycles)
bicycles.append('trek')
bicycles.remove('trek')#根据值删除,只删除第一个
print(bicycles)
Sort:
cars = ['bmw','audi','toyota','subaru']
cars.sort()
print(cars)
cars.sort(reverse = True)#按照字母相反的顺序排列
print(cars)
#使用sort()进行排列是永久性排列,如果想临时,sorted()
print("临时排列"+str(sorted(cars)))
cars.reverse()#反转
print(cars)
print(len(cars))#长度