You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pxl_oboard/listwork.py

25 lines
583 B

def unpack(string):
ll = string.split('-_')
ll.remove("") # Remove empty line
el_col = ll[0].count('-')
post_ll = []
for i in ll:
temp = i.split("-")
# Multi-add (2, 3 or 5 elements)
if el_col == 1:
post_ll.append([int(temp[0]), int(temp[1])])
elif el_col == 2:
post_ll.append([int(temp[0]), int(temp[1]), int(temp[2])])
elif el_col == 4:
post_ll.append([int(temp[0]), int(temp[1]), int(temp[2]), int(temp[3]), int(temp[4]) ])
return post_ll
def pack(ll):
string = ''
for el in ll:
for i in el:
string += str(i) + '-'
string += '_'
return string