def ranges(arr):
 if (not arr):
  return []
 res = []
 start = end = arr[0]
 for i in arr[1:]:
  if (i == (end + 1)):
   end = i
  else:
   if (start != end):
    res.append(('%s->%s' % (start, end)))
   start = end = i
 if (start != end):
  res.append(('%s->%s' % (start, end)))
 return res

def ranges ( arr ) : if ( not arr ) : return [ ] res = [ ] start = end = arr [ 0 ] for i in arr [ 1 : ] : if ( i == ( end + 1 ) ) : end = i else : if ( start != end ) : res . append ( ( '%s->%s' % ( start , end ) ) ) start = end = i if ( start != end ) : res . append ( ( '%s->%s' % ( start , end ) ) ) return res
para arr .