I think this would be clearer broken up into a couple of lines. E.g.

```
start, end = symbols_lines[symbol]
blocks.append('\n'.join(code[start:end])
```

Also, a few lines of spacing and explanatory comments wouldn't go amiss throughout the function.