Nested Lists Hackerrank Solution In Python