Typescript Index Last Element In Array Python Methods