Question: Please solve the following proglem with Python 3. Please comment liberally. # Create a generator that loops over the input iterable, # yielding one element
Please solve the following proglem with Python 3. Please comment liberally.
# Create a generator that loops over the input iterable, # yielding one element at a time, but skipping duplicates
# Note the output should be in the same order as the input iterable
""" Test in the REPL: >>> from HW3 import unique >>> numbers = [4, 5, 2, 6, 2, 3, 5, 8] >>> nums = unique(numbers) >>> next(nums)
# should return: 4 >>> next(nums) 5 >>> next(nums) 2 >>> next(nums) 6 >>> next(nums) 3 >>> next(nums) 8 >>> next(nums) Traceback (most recent call last): File "
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
