其他分享
首页 > 其他分享> > 20201224-1

20201224-1

作者:互联网

1-1
#
bicycles.py bicycles = ['trek', 'cannondale', 'redline', 'specialized'] message = "My first bicycle was a " + bicycles[0].title() + "." print(message)
--->
My first bicycle was a Trek.
1-2
# cars.py

cars = ['bmw', 'audi', 'toyota', 'subaru']

print("Here is the original list:")
print(cars)

print("\nHere is the sorted list:")
print(sorted(cars))

print("\nHere is the reverse alphabetical list:")
print(sorted(cars, reverse=True))

print("\nHere is the original list again:")
print(cars)
1-3
# motorcycles
motorcycles = ['honda', 'yamaha', 'suzuki', 'ducati'] 
print(motorcycles)

too_expensive = 'ducati'
motorcycles.remove(too_expensive)
print(motorcycles)
print("\nA " + too_expensive.title() + " is too expensive for me.")

注:知识点链接 

https://www.cnblogs.com/azxsdcv/p/14183819.html

https://www.cnblogs.com/azxsdcv/p/14183874.html

标签:motorcycles,cars,list,too,print,expensive,20201224
来源: https://blog.51cto.com/u_15149862/2834590