Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- l = ['a', 'b', 'new', 'c', 'd', 'f', 'fin', 'g', 'l', 'j']
- r = ['a', 'b', ['c', 'd', 'f'], 'g', 'l', 'j']
- def asd(l, index=0):
- r = []
- for i in l[index:]:
- index += 1
- if i == 'new':
- i, index = asd(l, index)
- r.append(i)
- if i == 'fin':
- return r
- return r, index
- r, index = asd(l)
Add Comment
Please, Sign In to add comment