vancake
0
Q:

next in python

#next(iterable, default)

#iterable ->	Required. An iterable object.
#default ->	    Optional. An default value to return if the iterable has reached to its end.

mylist = iter(["apple", "banana", "cherry"])
x = next(mylist, "orange")
print(x)
x = next(mylist, "orange")
print(x)
x = next(mylist, "orange")
print(x)
x = next(mylist, "orange")
print(x)

#o/p -> 
apple
banana
cherry
orange
3

New to Communities?

Join the community