Skip to main content
1 of 2
mercator
  • 369
  • 1
  • 7

Python 2, 73 bytes

A function that takes a string as input and returns a string representation of a Python list. Zero can be represented both by 0 and -0 (when it comes last):

lambda s:str(map(len,s.split('0'))).replace('0, ','-').replace('--','0,')
mercator
  • 369
  • 1
  • 7