Advertisement
Kevin_Zhang

Untitled

Nov 15th, 2020
742
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.20 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. a = [1,2,3,4,7,8,9,12]
  4. ans = []
  5.  
  6. lstv = a[0]
  7.  
  8. for i in a:
  9.     if i == lstv + 1:
  10.         ans[-1].append(i)
  11.     else:
  12.         ans.append([i])
  13.     lstv = i
  14.  
  15. print(ans)
  16.        
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement