timpin

Programming 101/lists

Aug 13th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. countries = ["UK","Ireland","France","Belgium","Netherlands","Luxembourg","Germany","Denmark"]
  2.  
  3. countries[:]
  4. Out[2]:
  5. ['UK',
  6. 'Ireland',
  7. 'France',
  8. 'Belgium',
  9. 'Netherlands',
  10. 'Luxembourg',
  11. 'Germany',
  12. 'Denmark']
  13.  
  14. countries.append("Slovakia")
  15.  
  16. countries
  17. Out[4]:
  18. ['UK',
  19. 'Ireland',
  20. 'France',
  21. 'Belgium',
  22. 'Netherlands',
  23. 'Luxembourg',
  24. 'Germany',
  25. 'Denmark',
  26. 'Slovakia']
  27.  
  28. countries.remove("UK")
  29.  
  30. countries
  31. Out[6]:
  32. ['Ireland',
  33. 'France',
  34. 'Belgium',
  35. 'Netherlands',
  36. 'Luxembourg',
  37. 'Germany',
  38. 'Denmark',
  39. 'Slovakia']
  40.  
  41. countries.insert(-2, "Czech Republic")
  42.  
  43. countries
  44. Out[8]:
  45. ['Ireland',
  46. 'France',
  47. 'Belgium',
  48. 'Netherlands',
  49. 'Luxembourg',
  50. 'Germany',
  51. 'Czech Republic',
  52. 'Denmark',
  53. 'Slovakia']
Advertisement
Add Comment
Please, Sign In to add comment