Advertisement
IvaSerge

ElementsInListByQueue

Dec 3rd, 2017
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.48 KB | None | 0 0
  1. elemList = IN[0]
  2. #Введенные в этом узле данные сохраняется в виде списка в переменных IN.
  3. outlist = list()
  4. tempList = list()
  5. countCheck = len(elemList) - 1
  6.  
  7. for i, element in enumerate(elemList):
  8.     #Если элемент единственный - сразу на выход.
  9.     if i == 0 and i == countCheck:
  10.         outlist.append(element)
  11.        
  12.     #Если элемент первый - просто добавляем его во временный список
  13.     elif i == 0 and i != countCheck:
  14.         tempList.append(element)
  15.    
  16.     #если элемент не первый, сверяем его с предидущим
  17.     #если элемент такойже, добавляем во временный список.
  18.     elif element == elemList[i-1] and i != countCheck:
  19.         tempList.append(element)
  20.    
  21.     #если другой, то временный список на выход,
  22.     #и создаем новый временный список.
  23.     elif element != elemList[i-1] and i != countCheck:
  24.         outlist.append(tempList)
  25.         tempList = list()
  26.         tempList.append(element)
  27.    
  28.     #Если элемент последний и равен
  29.     elif element == elemList[i-1] and i == countCheck:
  30.         tempList.append(element)
  31.         outlist.append(tempList)
  32.                
  33.     #Если элемент последний и не равен
  34.     elif element != elemList[i-1] and i == countCheck:
  35.         outlist.append(tempList)
  36.         outlist.append([element])
  37.                
  38. OUT = outlist
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement