Hackerrank Python List Solution