logo-MindMajix
PostPythonPython
c
cayrel rings

Posted on 25th July 2024|54 views

0
votes

Python Hasnext

Does python iterators got the hasNext method?

1 answers
Answers
P
Harshel Mike

Posted on 25th July 2024| views

There is an alternative for StopIteration by utilising next(iteration, default_value)

Example:

>>> a = iter('hey') 

>>> print next(a, None) 

>>> print next(a, None) 

>>> print next(a, None) 

y

>>> print next(a, None) 

None 

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo

  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos
Name
Course *
Email *
Phone Number