Python 学习笔记 列表 xxx XXX

骑猪看日落 2022-12-07 01:17 295阅读 0赞
  1. Python 学习笔记 列表 xxx XXX
  2. bicycles = ['trek', 'cannondale', 'redline', 'specialized']
  3. print(bicycles)
  4. print(bicycles[0])
  5. print(bicycles[0].title())
  6. print(bicycles[-1])
  7. names = ['wenwen', 'juanjuan', 'yuyu']
  8. for x in names:
  9. print(x)
  10. for i in range(0, 3):
  11. print(names[i].title() + " hello !")
  12. motorcycles = ['honda', 'yamaha', 'suzuki']
  13. print(motorcycles)
  14. motorcycles[0] = "ducati"
  15. print(motorcycles)
  16. motorcycles.append("honda")
  17. print(motorcycles)
  18. motorcycles.insert(1, 'xchn')
  19. print(motorcycles)
  20. del motorcycles[0]
  21. print(motorcycles)
  22. poped_motorcycle = motorcycles.pop()
  23. print(motorcycles)
  24. print(poped_motorcycle)
  25. motorcycles = ['honda', 'yamaha', 'suzuki']
  26. last_owned = motorcycles.pop()
  27. print("The last motorcycle I owned was a " + last_owned.title() + ".")
  28. motorcycles.remove("yamaha")
  29. print(motorcycles)
  30. xjcs = ['BL', 'HRB', 'BJ']
  31. print(xjcs)
  32. print(xjcs.pop())
  33. xjcs.append("BJ")
  34. for c in xjcs:
  35. print("wh:" + c)
  36. xjcs.insert(0, "TJ")
  37. xjcs.insert(2, "XT")
  38. xjcs.append("JMS")
  39. print(xjcs)
  40. while len(xjcs) != 2:
  41. print("wh: " + xjcs.pop())
  42. for c in xjcs:
  43. print("c: " + c)
  44. i = len(xjcs)
  45. j = 0
  46. while j < i:
  47. print(str(j) + " " + str(i))
  48. del xjcs[0]
  49. j += 1
  50. print("---")
  51. print(xjcs)
  52. print("---")

发表评论

表情:
评论列表 (有 0 条评论,295人围观)

还没有评论,来说两句吧...

相关阅读