iterator_obj: iterataor , from this elements are returned, StopIteration is raised if no element is left default_value: Optional, This value is returned if no element is left, otherwise StopIteration exception is raised.
We can use a default value to return when there is no item left to return. In such case no exception is raised.
my_str='abc'
my_str=iter(my_str)
print(next(my_str)) # a
print(next(my_str)) # b
print(next(my_str, 'x')) # c
print(next(my_str, 'x')) # x
print(next(my_str, 'x')) # x