Advertisement
MaxDvc

Lists

Nov 21st, 2019
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. def reverse(list):
  2. #@param:
  3. #   list: list;
  4. #   return: list;
  5.     lenght = len(list) -1
  6.     for i in range(0,lenght):
  7.         item1 = list[i]
  8.         item2 = list[lenght-i]
  9.         list[i] = item2
  10.         list[lenght-i] = item1
  11.     return list
  12. #-------------------------------------------------------------------------------
  13. def count(list,find):
  14. #@param:
  15. #   list: list;
  16. #   find: any;
  17. #   return: int;
  18.     count = 0
  19.     for i in list:
  20.         if find == i:
  21.             count = count+1
  22.     return count
  23. #-------------------------------------------------------------------------------
  24. def insert(L,n1,n2):
  25. #@param:
  26. #   L: list of int;
  27. #   n1, n2: int;
  28.     list = []
  29.     for i in range(0,len(L)):
  30.         if L[i] == n1:
  31.             list.append(L[i])
  32.             list.append(n2)
  33.         else:
  34.             list.append(L[i])
  35.     return list
  36. #-------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement