daily pastebin goal
3%
SHARE
TWEET

Untitled

a guest Dec 9th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. names=['dipendra','roshan','sabuj','santosh']
  2. extra_name= ['radhe','nigma','rahul']
  3. names.append(extra_name)
  4. print(names)
  5. # iterable for extend
  6. a=[1,2,4]
  7. b=["nose"]
  8. a.extend(b)
  9. print(a)
  10.  
  11. #index
  12. print(a.index(4))
  13.  
  14. #insert to insert value insert(index,new_value)
  15. name=['a','b','c','e']
  16. print(name)
  17. name.insert(1,'d')
  18. print(name)
  19.  
  20. # pop to pop value from the stack bottom
  21.  
  22. name.pop(1)
  23. print('after pop',name)
  24.  
  25. # remove remove first occurence of value
  26. name.remove('a')
  27. print('Value after remove',name)
  28.  
  29. # reverse
  30. name.reverse()
  31. print(name)
  32.  
  33. #sort to sort value
  34. name.sort()
  35. print(name)
  36.  
  37. # sort and reverse
  38. name.sort(reverse=True)
  39. print(name)
  40.  
  41. #delete value (del)
  42. del name[2]
  43. print(name)
  44.  
  45. # for loop in list
  46.  
  47. values=['axe','ball','cat','dog']
  48. for i in values:
  49.     print(i)
  50.  
  51. # for loop with enumerators
  52. for i in enumerate(values):
  53.     print(i)
  54.  
  55. # enumerate
  56. names=['santosh','dipak','class']
  57. for i in enumerate(names):
  58.     print(i)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top