Guest User

Untitled

a guest
Dec 9th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #1 .append()
  2.  
  3. names = ['santosh','roshan','sabuz','rahul',]
  4. abc = names
  5. mno = abc
  6. xyz = mno.copy()
  7. print(id(abc))
  8. print(id(names))
  9. print(id(mno))
  10. print(id(xyz))
  11. xyz.append('dependra')
  12. print(mno)
  13. print(names)
  14. print(xyz)
  15.  
  16.  
  17. #2 .count()
  18.  
  19. name = ['santosh','roshan','sabuz','rahul','santosh']
  20. print(name.count('santosh'))
  21.  
  22.  
  23. #3 .extend()
  24.  
  25. name = ['santosh','roshan','sabuz','rahul','santosh']
  26. extra_name = ['dipendra','nigma']
  27. name.extend(extra_name)
  28. print(name)
  29.  
  30.  
  31.  
  32. #4 .index()
  33.  
  34. name = ['santosh','roshan','sabuz','rahul','santosh']
  35. print(name.index('santosh'))
  36. print(name.index('santosh',1))
  37.  
  38.  
  39. #5 .insert(index, obj)
  40.  
  41. name = ['santosh','roshan','sabuz','rahul','santosh']
  42. name.insert(3, 'om')
  43. print(name)
  44.  
  45.  
  46. #6 .pop()
  47.  
  48. name = ['santosh','roshan','sabuz','rahul','santosh']
  49. name.pop()
  50. print(name)
  51. name.pop(2)
  52. print(name)
  53.  
  54.  
  55. #7 .remove()
  56.  
  57. name = ['santosh','roshan','sabuz','rahul','santosh']
  58. name.remove('sabuz')
  59. print(name)
  60.  
  61.  
  62. #8 .reverse()
  63.  
  64. name = ['santosh','roshan','sabuz','rahul','santosh']
  65. name.reverse()
  66. print(name)
  67.  
  68.  
  69. #9 .sort()
  70.  
  71. name = ['santosh','roshan','3','1','sabuz','rahul','santosh']
  72. name.sort()
  73. print(name)
  74.  
  75. name.sort(reverse=True)
  76. print(name)
  77.  
  78.  
  79. # del
  80.  
  81. name = ['santosh','roshan','3','1','sabuz','rahul','santosh']
  82. del name
  83. print(name)
Add Comment
Please, Sign In to add comment