返回列表 發帖
  1. # -*- coding: utf-8 -*-
  2. """
  3. Spyder Editor

  4. This is a temporary script file.
  5. """
  6. list1 = [2,1,"忠","孝","仁","愛","信","義","和","平"]
  7. print("原始list1",list1)
  8. #list新增
  9. list1.append(-20)   #最後+
  10. print("append一元素",list1)
  11. list1.insert(1,5)   #指定+
  12. print("insert一元素",list1)


  13. #list清除
  14. list1.pop() #最後-
  15. print("pop一元素",list1)
  16. list1.remove(5) #指定-
  17. print("remove一元素",list1)


  18. list2=[12,-3,-50,32,25,11]


  19. print("原始list2:",list2)
  20. list2.sort(reverse=1)
  21. print("排序list2:",list2)        
複製代碼

TOP

返回列表