fork(1) download
  1. # your code goes here
  2. #!/usr/bin/env python3
  3. array = ['a', 'b', '-', 'a', 'b', 'c', '-', '','-','-']
  4.  
  5. def split_da_list(myarray, myseparator='', include=False):
  6. sep_list = []
  7. start = 0
  8. while True:
  9. try:
  10. end = myarray.index(myseparator, start) + include
  11. sep_list.append(myarray[start:end])
  12. start = end + (not include)
  13. except ValueError:
  14. break
  15. return sep_list
  16.  
  17. print (split_da_list(array, '-', include=True))
  18.  
Success #stdin #stdout 0.01s 7340KB
stdin
Standard input is empty
stdout
[['a', 'b', '-'], ['a', 'b', 'c', '-'], ['', '-'], ['-']]