Nested List Hackerrank Solution In Python