A small fix for python indexing

length and tlen were not updated with +1 for indexing