Re: Iterator instances not independent
Francis Belliveau via Tutor <[email protected]> Mon, 8 Dec 2025 07:45:48 -0500
| Newsgroups | gmane.comp.python.tutor |
|---|---|
| Message-ID | <[email protected]> |
Thank you Sarfraaz. You are absolutely correct in that next() was being called at the top of the loop as well as in the print statement. I also accept the validity of your statement regarding the separation of object and iterator. In my defense, this is just an example exercise while working my way through learning python. Fran > On Dec 8, 2025, at 04:41, Sarfraaz Ahmed <[email protected]> wrote: > > Hello Fran, > > My first guess is that the "for" loop is also doing a "next" on seqA ( apart from the explicit next() in the print statement at the end of the loop ) > > Add some print statements to your class methods to follow the code flow. It might give you some hints. > > Also, it would help if you have a separate Iterator class. Thus separating out the operations on Sequence and its Iterations. > -- > Jazaak Allahu Khair > -- Sarfraaz Ahmed _______________________________________________ Tutor maillist - To unsubscribe send an email to [email protected] To unsubscribe or change subscription options: %(web_page_url)slistinfo/%(_internal_name)s