Arbitrary Shopping Hackerrank Solution Python