Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- elemList = IN[0]
- #Введенные в этом узле данные сохраняется в виде списка в переменных IN.
- outlist = list()
- tempList = list()
- countCheck = len(elemList) - 1
- for i, element in enumerate(elemList):
- #Если элемент единственный - сразу на выход.
- if i == 0 and i == countCheck:
- outlist.append(element)
- #Если элемент первый - просто добавляем его во временный список
- elif i == 0 and i != countCheck:
- tempList.append(element)
- #если элемент не первый, сверяем его с предидущим
- #если элемент такойже, добавляем во временный список.
- elif element == elemList[i-1] and i != countCheck:
- tempList.append(element)
- #если другой, то временный список на выход,
- #и создаем новый временный список.
- elif element != elemList[i-1] and i != countCheck:
- outlist.append(tempList)
- tempList = list()
- tempList.append(element)
- #Если элемент последний и равен
- elif element == elemList[i-1] and i == countCheck:
- tempList.append(element)
- outlist.append(tempList)
- #Если элемент последний и не равен
- elif element != elemList[i-1] and i == countCheck:
- outlist.append(tempList)
- outlist.append([element])
- OUT = outlist
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement