nums=[0,1,2,4,5,7]
result=[]
def summaryRanges(nums):
if not nums: return []
res = []
i = 0
while i < len(nums):
j = i
print j
while j < len(nums) - 1 and nums[j] == nums[j + 1] - 1:
j += 1
print j,'debug'
if j == i:
print j,i
res.append(str(nums[i]))
else:
res.append('%s->%s' % (str(nums[i]), str(nums[j])))
i = j + 1
return res
t=summaryRanges(nums)
print t
[‘0->2’, ‘4->5’, ‘7’]