Guest User

Untitled

a guest
Oct 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. l = ['a', 'b', 'new', 'c', 'd', 'f', 'fin', 'g', 'l', 'j']
  2.  
  3. r = ['a', 'b', ['c', 'd', 'f'], 'g', 'l', 'j']
  4.  
  5. def asd(l, index=0):
  6. r = []
  7. for i in l[index:]:
  8. index += 1
  9. if i == 'new':
  10. i, index = asd(l, index)
  11. r.append(i)
  12. if i == 'fin':
  13. return r
  14. return r, index
  15.  
  16. r, index = asd(l)
Add Comment
Please, Sign In to add comment