Your question is Iterator Implementation and Usage. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Foursquare Explore may return a sequence of ranked venue results that a caller consumes one at a time. Implement an iterator supporting next() and hasNext() without modifying the underlying results.
Your solution must provide a run_iterator(values, operations) function. It receives a list of result identifiers and a list of operations, then executes them in order. The operation "hasNext" returns whether another result is available. The operation "next" returns the next result and advances the iterator. If next() is called after exhaustion, return None.
The iterator should maintain only its current position and must not remove elements from the input list. Return a list containing the result of every operation, preserving operation order.
values: a list of integers representing Explore result identifiers.operations: a list containing only the strings "next" and "hasNext".None, with one entry per operation.def run_iterator(values, operations):