#61 Python Tutorial for Beginners | Iterator

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ก.ย. 2024
  • Github :- github.com/nav...

ความคิดเห็น • 284

  • @sohailanwar7536
    @sohailanwar7536 3 ปีที่แล้ว +69

    In pycharm you can use (control + d) to copy the line and paste it onto the next in the place of using (ctrl + c) and (ctrl + v).

    • @mehulsharma7333
      @mehulsharma7333 2 ปีที่แล้ว +2

      Thanks 👍

    • @gokulkrishnayt
      @gokulkrishnayt 2 ปีที่แล้ว +1

      Thanks Buddy😊

    • @atlasatlantis8447
      @atlasatlantis8447 ปีที่แล้ว +2

      I'm pretty sure it's the same for all windows programs. You can even copy youtube comments this way.

    • @AshiqAli-ie5pm
      @AshiqAli-ie5pm 11 หลายเดือนก่อน

      Thanks bro

  • @divyanshusingh6105
    @divyanshusingh6105 4 ปีที่แล้ว +19

    I really Want to thank you Navin Sir..My college faculty never focus on the concepts of programming they are just making us rattutota... Thank you so much sir for coming on youtube and helping the students

    • @balla4004
      @balla4004 4 ปีที่แล้ว +1

      What is meant by rattutato

    • @rayyanamir8560
      @rayyanamir8560 3 ปีที่แล้ว

      @@balla4004 He means rattu tota.

    • @amalayakin4411
      @amalayakin4411 2 ปีที่แล้ว

      Our college also the same scenarios happens

    • @vishutanwar
      @vishutanwar 2 ปีที่แล้ว

      @@balla4004 means they just make student memorise programing

  • @jimmymesa
    @jimmymesa 5 ปีที่แล้ว +13

    print(next(values)) prints 1 and also changes the state of the iterator after which num = 2. So the for loop will print the numbers from 2 to 10.

  • @swethasundaram04
    @swethasundaram04 3 ปีที่แล้ว +14

    The raise keyword is used to raise an exception. You can define what kind of error to raise(here its StopIteration).

    • @shivasaiprasadakula7386
      @shivasaiprasadakula7386 3 ปีที่แล้ว +1

      I was made mistake while Entering the code like (stopiteration...but the s should be caps ) after watching your comment I entered Caps S Now I Got the correct code without error thanks... 👍🥰

  • @sriram9786
    @sriram9786 4 ปีที่แล้ว +20

    sir can you put another vedio on this. i dint understand completely.

  • @adilbougma2706
    @adilbougma2706 4 ปีที่แล้ว +14

    omg you are a true programmer :D i lauoh so hard when the output print None. i like you debuging method

  • @chandrasekar3653
    @chandrasekar3653 5 ปีที่แล้ว +6

    I just debug and found how that statement for i in values just calls the next function in Topten class , every time after printing the value of i . This is awesome . You should include a debug session in this video itself.

    • @nithinsamudrala9697
      @nithinsamudrala9697 4 ปีที่แล้ว +1

      Chandra Sekar how can for loop call next method?

  • @Shrishivbharat
    @Shrishivbharat 5 ปีที่แล้ว +22

    Sir, when will you make videos on tikinter and other python GUI?

  • @zakiasmaa6834
    @zakiasmaa6834 24 วันที่ผ่านมา

    I really want to Thank you Sir for all the efforts and also for your nice energy, I hope that you still have this awsome energy and vibes, God bless you !!!

  • @naesone2653
    @naesone2653 3 ปีที่แล้ว +5

    wow you really explain well and are one of the few indians that have no accent almost respect

  • @HackingWithCoffee
    @HackingWithCoffee 5 ปีที่แล้ว +64

    Sir can you please create video on data structure and algorithm

  • @harshamin7996
    @harshamin7996 2 ปีที่แล้ว +8

    Sir,
    Why can't we use break in else part to stop the execution of for loop ?

    • @realsumitkumar
      @realsumitkumar 2 ปีที่แล้ว +2

      Break is used only inside a loop

  • @utpalpodder-pk6vq
    @utpalpodder-pk6vq 4 ปีที่แล้ว +4

    whether during the creation of the object itself __iter__() method is called just like __init__() method?
    Is __iter__() method is called only once?

  • @pradeepmedikonda7282
    @pradeepmedikonda7282 5 ปีที่แล้ว +31

    What is the use of iterator while we have a for loop and we can go for a every element of the list....

    • @adnanfaisal1085
      @adnanfaisal1085 4 ปีที่แล้ว +3

      same queston

    • @moisesdiaz9852
      @moisesdiaz9852 4 ปีที่แล้ว

      same question here too

    • @moisesdiaz9852
      @moisesdiaz9852 4 ปีที่แล้ว +5

      I just found it, its because iterators use much less resources than the traditional loop

    • @sanjaykrish8719
      @sanjaykrish8719 4 ปีที่แล้ว +8

      internally the list is an iterator that has next and iter methods implemented and that's why you could use the for loop in list. What Navin teaches is you could create your own custom iterator

    • @bmanicharanreddy7386
      @bmanicharanreddy7386 4 ปีที่แล้ว +2

      actually for loop made up of iterator object

  • @pinakibhattacharya2761
    @pinakibhattacharya2761 4 ปีที่แล้ว +9

    and instead of giving exception in else part can we give break statement at the end of if statement?

    • @rajeshwardutta
      @rajeshwardutta 4 ปีที่แล้ว +2

      I don't think you could. Break works for loops, but IF is a conditional operator.

    • @puneet8705
      @puneet8705 4 ปีที่แล้ว

      not break
      but breakpoint will work

    • @addagallanaresh4044
      @addagallanaresh4044 3 ปีที่แล้ว

      @@rajeshwardutta switch is also conditional entry but it supports break..its not a loop

  • @anuragrsimha
    @anuragrsimha 4 ปีที่แล้ว +1

    ಸರ್...ನಿಮ್ಮ teaching ನನಗೆ ಬಹಳ ಇಷ್ಟ. ಈ videoಇಂದ ನನ್ನ ಎಲ್ಲಾ doubtಗಳು clear ಆದವು. ಧನ್ಯವಾದಗಳು.
    సర్...మీరు teaching నాకు చాలా ఇష్టం. ఈ video నుండి నా అన్ని doubtలు clear ఆయింది. ధన్యవాదలు.
    ಜೈ ಕರ್ನಾಟಕ (జై కర్నాటక)!!
    ಜೈ ಕನ್ನಡ (జై కన్నడ)!!

    • @nuqlear1189
      @nuqlear1189 3 หลายเดือนก่อน

      kannada pig idli sambhar

  • @mohamednayeem2602
    @mohamednayeem2602 6 หลายเดือนก่อน

    this we can use for interview question but for loop is the best. I haven't used this loop in my entire life

  • @prsh1989
    @prsh1989 5 ปีที่แล้ว +11

    why we use iterator? I mean if we have for loop, then why iterator? Any real world programming example where this is used?

    • @sheikwaris
      @sheikwaris 4 ปีที่แล้ว

      have same question

    • @naveensai4039
      @naveensai4039 6 หลายเดือนก่อน +2

      @prsh1989 for suppose, if u have a string list and then u r trying to check if the list contains one particular value then u need to use iterator to check whether that specific value is present or not. Let us consider another example, suppose u r building a well built structure and if u don't know the length of list or any collections then u need to use next method in iterator and fetch the values if the list contains values in list

  • @ryouko2971
    @ryouko2971 5 ปีที่แล้ว +1

    Under the def __iter__() method, why are we returning self only? And what does he mean by 'returning the object' when using this method? It's just a self keyword with no parameters. What does this mean? Please help

    • @guru_bro
      @guru_bro 3 ปีที่แล้ว +1

      Bro do u got ur answer please explain me. I'm stuck for days

  • @sivasaran4
    @sivasaran4 3 ปีที่แล้ว +2

    can we use break instead of "raise stop iteration"

    • @virtualmagic5489
      @virtualmagic5489 3 ปีที่แล้ว +2

      same doubt

    • @karthikreddy4430
      @karthikreddy4430 3 ปีที่แล้ว

      @@virtualmagic5489 break can only be used in for loop and switch i guess

  • @omkarmore7017
    @omkarmore7017 4 ปีที่แล้ว +1

    Can someone or Navin tell me this that why are we not converting that TopTen class object 'values' to iterator object i.e like values = iter(values)
    As you are not creating iterator object in last example how is __iter__ method getting called or how is it working without it.
    As far as i know if we create an object of class only init method gets performed without calling.
    Please Help me with this.
    And Cheers to your work Navin.
    Thank you very much

  • @shaiksubhan2306
    @shaiksubhan2306 5 ปีที่แล้ว +2

    What is going on behind for loop it is good,,,, but what is the use of iterator

  • @ursABD
    @ursABD ปีที่แล้ว +1

    In if condition can we use break to stop the iteration 9:33

  • @KoreanPanda
    @KoreanPanda 3 ปีที่แล้ว

    I'm confused. Couldn't we just print "nums" to output the values? Why did we need a "for" statement to display all 4 values?

  • @BryceDoesLife
    @BryceDoesLife 5 ปีที่แล้ว +14

    This was exactly what I needed thank you

    • @bhu1868
      @bhu1868 3 ปีที่แล้ว

      seems like you are an music artist, do u use python in music some way?

  • @shrihari8886
    @shrihari8886 4 ปีที่แล้ว +1

    hiii bro, create the own class that not repeat again values...but inbuild the value or nums it can repeating ....i wanna clear about it this video

  • @akashgandhi7886
    @akashgandhi7886 4 ปีที่แล้ว +2

    first example in list: values are repeated but while creating our own iterator values not repeated why this is happen plzz give me the difference of this scenario

    • @HassanRahamathullah
      @HassanRahamathullah 3 ปีที่แล้ว

      In first example with list, if you observe carefully, he is performing for loop on the list object not on the iterator (it). If you perform for loop on "it" it would continue from where you left using "it.__next__()" function.

  • @zeeshanshahidansari9425
    @zeeshanshahidansari9425 4 ปีที่แล้ว +3

    Nice mustache! It suits you Sir. :-)

  • @prachinainawa3055
    @prachinainawa3055 5 ปีที่แล้ว +2

    It will be very very gladful if you give sometime in answering the good questions asked by us. Because we get into some confusion whose answers are not available on google. Then we got stucked there. So please at least give us any opportunity to get the confusion clear in between 2 days so that we will also don't lose the interest in clearing the questions.
    If you don't have that much time then you can also answer only necessary and tough questions.

    • @OasisFinder
      @OasisFinder 3 ปีที่แล้ว +1

      agree..
      but thing is not everyone read comments or those who read dont go deep down in comment section,
      Just like i replied your comment after one year lol

    • @guru_bro
      @guru_bro 3 ปีที่แล้ว

      Can u help for one doubt please I'm stuck for days

    • @OasisFinder
      @OasisFinder 3 ปีที่แล้ว

      @@guru_bro Where?

    • @guru_bro
      @guru_bro 3 ปีที่แล้ว

      @@OasisFinder what does iter Dunder method do and y it returns self what is the use of returning same object which is passed?

  • @sagarr1640
    @sagarr1640 3 ปีที่แล้ว +1

    By this way are v overloading the Iter & next inbuilt function ?

  • @Bhabani1994
    @Bhabani1994 5 ปีที่แล้ว

    concept is extremely good no doubt on that, but your new look does not matching with personality.....
    but really your teaching style is awesome, thank god that you are providing such valuable knowledge with free of cost...

  • @30.ayushyadav41
    @30.ayushyadav41 หลายเดือนก่อน

    instead of for why we don't use
    while i

  • @komaljoshi2272
    @komaljoshi2272 5 ปีที่แล้ว +3

    hi sir,I don't have IT background ,completed B.Sc. Zoology in 2013, now keen to join IT field,so can I start my career in Python ? Are jobs available for fresher Python Developer in market? Could you please guide?

    • @anujdahiya341
      @anujdahiya341 5 ปีที่แล้ว

      i'm in somewhat same situation

    • @OasisFinder
      @OasisFinder 3 ปีที่แล้ว

      Python is booming in terms of job in 2020.
      even if you are not from IT learn this , take your time and you can

  • @TrendingInfo124
    @TrendingInfo124 3 ปีที่แล้ว +2

    '1' will be printed twice as the 'for loop' always starts from the 1st element in the list. so both are different things and it will give the twice ones then will continue up to what we want to print.

    • @aflous
      @aflous 3 ปีที่แล้ว

      nope

  • @narragopichand9982
    @narragopichand9982 3 ปีที่แล้ว

    If something is returned in a function it return value to function call right ? What is happening to return here. Object is being returned......

  • @haaahaaa8396
    @haaahaaa8396 4 ปีที่แล้ว +4

    Sir, where have you learnt all this stuff .
    I am watching the whole series,your concepts are strong.
    Can you please tell me which course or way should I choose ,
    For web development via. Python.
    I am cs student.
    2nd yr

    • @mohammadmohsinmohammedmohs9717
      @mohammadmohsinmohammedmohs9717 4 ปีที่แล้ว

      Even I am second year student, can you tell whether you are understanding oops concepts?? I'm not able to get it

    • @hxrsh_x
      @hxrsh_x 3 ปีที่แล้ว

      @@mohammadmohsinmohammedmohs9717 seach for "Corey Schafer OOPs tutorial in Python"

    • @OasisFinder
      @OasisFinder 3 ปีที่แล้ว +1

      The way sir explain things is clear that its his past over all experience and strong understanding of OOPs,
      The reason i said this because every developer has its own way to clear concepts, Maybe you clear your concepts by watching or reading other videos or book.

    • @amritanshusinghbhumihar
      @amritanshusinghbhumihar 2 ปีที่แล้ว

      Experience.

  • @vikaspal2799
    @vikaspal2799 3 ปีที่แล้ว +3

    Why do we need the iter() method while defining our own iterator???

    • @user-rn6zc7vp3h
      @user-rn6zc7vp3h 3 ปีที่แล้ว

      Yeah no need of iter if our class have next method and we are not even calling iter

    • @dobbysurfs
      @dobbysurfs 11 หลายเดือนก่อน

      You are making your object an iterator ,next method can only be used if there is an iterator.

  • @rakeshmali1727
    @rakeshmali1727 7 หลายเดือนก่อน

    at 5:11, why did the for loop print 7 and 8 again? this contradicts with 10:22 no?

  • @mayankrajput2889
    @mayankrajput2889 หลายเดือนก่อน

    Can we say we are using method overloading here?

  • @pothalasiva4820
    @pothalasiva4820 4 ปีที่แล้ว +2

    Sir why can't we use break statement 🤔🤔

    • @prakharprakashverma2409
      @prakharprakashverma2409 4 ปีที่แล้ว +1

      bcoz break keyword is used to break loops but here if condition is used

  • @keerthichowdary750
    @keerthichowdary750 4 ปีที่แล้ว +1

    sir!!!! in the before example u have shown the repeation of values getting in output...but in this example why it is not repaeting 1 and taking next values......

    • @dhamoramesh8210
      @dhamoramesh8210 3 ปีที่แล้ว

      have you cleared that doubt ? if yes please explain

  • @farazahmed1668
    @farazahmed1668 5 ปีที่แล้ว +5

    Hello sir, love from Pakistan...!

  • @malakhassan9816
    @malakhassan9816 4 หลายเดือนก่อน

    How we typed self.num and we hadn't typed method named num or class nemed num?..num is not defined..

    • @telugu_rockzz
      @telugu_rockzz 28 วันที่ผ่านมา

      It is not a parameter it just initialised

  • @bantigarg740
    @bantigarg740 4 ปีที่แล้ว

    Hey if we have for loop to print 1 to 10 number, why should we use this iterator

  • @tanmayisharma5890
    @tanmayisharma5890 11 หลายเดือนก่อน

    What happens if we print(next(it)) beyond the range of list? I mean what if we use print statement 6 time if the list has only 5 values? And can we access the index of an element using iter() and next()?

  • @Engineerincubicle
    @Engineerincubicle 5 ปีที่แล้ว +8

    Sir, My Final Year Project is on Virtual Mouse using Hand gestures using OpenCV and Python,Can you please help me in this,Sir?

    • @merowe123
      @merowe123 4 ปีที่แล้ว +1

      Nothing is free

  • @RamKaruna-em3xh
    @RamKaruna-em3xh 5 หลายเดือนก่อน

    Sir other way to stop the loop is self.num=self.num+0 , is this right sir

  • @shivangigoel9170
    @shivangigoel9170 5 ปีที่แล้ว +1

    class TOPT:
    def __int__(self):
    self.num=1
    def __iter__(self):
    return self
    def __next__(self):
    if self.num

    • @shivangigoel9170
      @shivangigoel9170 5 ปีที่แล้ว

      @Leonardo cool thanks

    • @chandusree3248
      @chandusree3248 5 ปีที่แล้ว

      That is --init-- not --int--

    • @subasrim962
      @subasrim962 4 ปีที่แล้ว

      Your mistakes for loop...for I in values
      Print (i)

  • @anoshkaniskar1482
    @anoshkaniskar1482 3 ปีที่แล้ว

    The when you say Iterators. How cool is that..

  • @startjourney8631
    @startjourney8631 3 ปีที่แล้ว +1

    Dil se dhanywaad🙏✌️🤗

  • @sakthivadivel1057
    @sakthivadivel1057 3 ปีที่แล้ว

    class TopTen:
    def __init__(self):
    self.num=1
    def __iter__(self):
    return self
    def __next__(self):
    val=self.num
    self.num += 1
    return val
    values = TopTen()
    for i in values:
    print(i)
    ------------
    i'm getting error like: TypeError: 'TopTen' object is not iterable
    ------------
    Could'u help me to fix this ?

  • @muzikizmylyf8411
    @muzikizmylyf8411 5 ปีที่แล้ว +1

    I like your learning style

  • @mounikak3818
    @mounikak3818 3 ปีที่แล้ว

    what is the use i dint understand
    when u want to print one by one it is done in 1st example
    bt in 2ns e ample own iterator all numbers are printed at once not as u told one by one
    dint understand what’s the real use u want to tell sir

  • @siddharthrautara8811
    @siddharthrautara8811 4 ปีที่แล้ว +2

    sir can you let us know a real life example where we use iterator

  • @saicharan4669
    @saicharan4669 4 ปีที่แล้ว

    Sir the video is a little bit confusing regarding creating an our own object of iterator
    My doubt is initial part of video we created our own iterator object that is it,then what is the difference

  • @Shubhamfoodshorts
    @Shubhamfoodshorts 3 ปีที่แล้ว

    since we already have for loop to iterate the list then why are we making things more complex by making this iterator

  • @hassnainamjad1059
    @hassnainamjad1059 3 ปีที่แล้ว

    modified iterators form where to start and where to stop:
    class ur_choice:
    def __init__(self, num):
    self.nums = int(input('enter from where to start'))
    def __iter__(self):
    return self
    def __next__(self):
    if self.nums

  • @srushtiagarwal2748
    @srushtiagarwal2748 5 ปีที่แล้ว +7

    very interesting and knowledgeable tutorial.👌👍

    • @KeremAli-cm3pj
      @KeremAli-cm3pj 2 หลายเดือนก่อน

      Also very interesting mustache
      (❁´◡`❁)(●'◡'●)

  • @yashsalvi6850
    @yashsalvi6850 4 ปีที่แล้ว +2

    Can someone help me know that what happens after "for i in values " is called ?

    • @ContentArm
      @ContentArm 4 ปีที่แล้ว

      __iter__() is called and then __iter__() calls __next__().
      __next__() runs till the exception is raised.

    • @guru_bro
      @guru_bro 3 ปีที่แล้ว

      @@ContentArm can u elaborate on this please maybe on insta

  • @ahmetsarkaya9203
    @ahmetsarkaya9203 4 ปีที่แล้ว

    "try and except" also could be used right? Was there any reason that stopped you to use "try and except" ?

  • @pratikgon522
    @pratikgon522 4 ปีที่แล้ว

    if I use exit() instead of Raise Iteration then what problem would I face?

  • @iamniks
    @iamniks 4 ปีที่แล้ว

    sir i have a question
    Why u used " raise StopIteration " ? why not u use " Break " instead ??? please explain anyone

    • @OasisFinder
      @OasisFinder 3 ปีที่แล้ว

      break works on LOOPs "for" or "while" not conditions like "if"

  • @rajeshg8649
    @rajeshg8649 4 ปีที่แล้ว

    Sire, in object creation we have created __iter__ function but we didn't called to make that object as iterator. Then how does it work???

  • @sepehrtavakoli591
    @sepehrtavakoli591 11 หลายเดือนก่อน

    It prints 1to10 but if we remove for loop it will give you only one

  • @sowmya6005
    @sowmya6005 3 ปีที่แล้ว

    why even without calling iter and next methods they are running

  • @rajkumar-nx1me
    @rajkumar-nx1me 5 ปีที่แล้ว +1

    sir what is the advantage of iterator over for loop

  • @pinakibhattacharya2761
    @pinakibhattacharya2761 4 ปีที่แล้ว +1

    sir in the above example we are not calling the iter() and next() method even then it executes how?

  • @banti000
    @banti000 5 ปีที่แล้ว +4

    Iter is linked to next , how and what it's doing,(return self) !

    • @harshavardhandsh5190
      @harshavardhandsh5190 5 ปีที่แล้ว +1

      I could not understand the benefits of iterator over cute for loop

    • @aldrinsaurovsarker5159
      @aldrinsaurovsarker5159 3 ปีที่แล้ว

      @@harshavardhandsh5190 used in data structures

  • @mohammadziauddin6270
    @mohammadziauddin6270 ปีที่แล้ว

    There was an indentation error at return val thats why its repeating., remove 1 space before return.

  • @tanaysamanta4730
    @tanaysamanta4730 3 ปีที่แล้ว

    def __iter__(self):
    return self
    What is the reason of using it? Can anyone explain?

  • @mahdi-hasan
    @mahdi-hasan ปีที่แล้ว

    If you want to work the loop for multiple times put "self.num = 1" in else condition.

  • @abhishekroushan9735
    @abhishekroushan9735 4 ปีที่แล้ว

    is there any way of using variable in place of self.num = 1 means self.num = n and then iterate it for 10 times

  • @cinemaplus150
    @cinemaplus150 4 ปีที่แล้ว +1

    Sir can u make video for machine learning usking sklearn lib for data science

  • @virtualmagic5489
    @virtualmagic5489 3 ปีที่แล้ว

    What does that __iter__() method do here sir

  • @nilimasharma6849
    @nilimasharma6849 2 หลายเดือนก่อน

    Instead of raise stop iteration can't we just use a break statement after else

    • @telugu_rockzz
      @telugu_rockzz 28 วันที่ผ่านมา

      No we can't use it

  • @veeramallabhoomika3435
    @veeramallabhoomika3435 4 ปีที่แล้ว

    Sir, At last when we call print values then we should two ones because of init function and other one is because of iter function but we are getting only one value of 1. I am not understanding this can you help me in this.

    • @TheProgrammingJourney
      @TheProgrammingJourney 3 ปีที่แล้ว

      This is because the iter is storing the value of self and that is none other but 1 in beginning but when the next()is called the value of the value of the self.num became 2 which would be passed as self in iter next time (in the for loop)

  • @hamzabohra3267
    @hamzabohra3267 3 ปีที่แล้ว

    sir why are we using raise ? can we not use break

  • @anonymous_anonymity
    @anonymous_anonymity 5 ปีที่แล้ว +2

    Excellent tutorial 👍👍

  • @harshgupta9761
    @harshgupta9761 4 ปีที่แล้ว

    Why only return self is use under iter block

  • @Abhishekkumarsingh-sl5yz
    @Abhishekkumarsingh-sl5yz 5 ปีที่แล้ว +1

    sir after class python is becoming difficult any suggestion

  • @kamalpathak4065
    @kamalpathak4065 4 ปีที่แล้ว

    So why we use loop if we have iterators

  • @santhoshbyri125
    @santhoshbyri125 4 ปีที่แล้ว +1

    break also possible

  • @avert_
    @avert_ 5 ปีที่แล้ว

    what is the use of __init__(self)? why cant we simply use val and increment values to it?

    • @telugutravellerraj
      @telugutravellerraj 5 ปีที่แล้ว

      __init__ is to initialize the variable, here 'num'.

  • @paulhaso
    @paulhaso ปีที่แล้ว

    Excellent video! Thank you

  • @abhiramjoshi9233
    @abhiramjoshi9233 5 ปีที่แล้ว

    What is the significance of returning the object itself? I cannot understand why we cannot use the "values" object itself for the iteration. Please help.

    • @ravirobust9499
      @ravirobust9499 5 ปีที่แล้ว +1

      __init__ is a special method in Python classes, it is the constructor method for a class.
      It is called when ever an object of the class is constructed.

    • @guru_bro
      @guru_bro 3 ปีที่แล้ว

      @@ravirobust9499 hi bro can u please elaborate a little more on this? I'm stuck on it for days maybe on insta ?

  • @MrHmm-cv6gs
    @MrHmm-cv6gs 4 ปีที่แล้ว +3

    can't we go like that
    for i range(1,11)
    print(next(value))

    • @dobbysurfs
      @dobbysurfs 11 หลายเดือนก่อน

      The logic for inbuilt "for loop " is itself iterator concept only.but if you want to use "for loop" for your own created objects you have to define a iterator

  • @pramitharyan5167
    @pramitharyan5167 4 ปีที่แล้ว +1

    one more video on iterator please

  • @venkatratnam4891
    @venkatratnam4891 3 ปีที่แล้ว

    after a long time i have seen your mustache

  • @yamini_ramesh7433
    @yamini_ramesh7433 4 ปีที่แล้ว

    Object is not iterable sir what's the prblm

  • @narendrasompalli5536
    @narendrasompalli5536 4 ปีที่แล้ว

    Sir why did you use if statement in next method. Is there any problem ,if we use (if statement) in for loop

  • @pawnage3
    @pawnage3 3 ปีที่แล้ว

    Thank you Mr. Reddy!

  • @karthick2237
    @karthick2237 5 ปีที่แล้ว +2

    No need to raise an Exception here, The return statement should belongs to if block. Then it'll be fine 👍

  • @bharathkumar5870
    @bharathkumar5870 4 ปีที่แล้ว

    list is already an iterator.why making it iterator again

  • @Rajadahana
    @Rajadahana 2 ปีที่แล้ว

    If you type
    print(next(values))
    after the for loop, you will get an Error.

  • @arkeys8764
    @arkeys8764 4 ปีที่แล้ว

    Where are we calling next function in for loop and without calling it how the value are printing??

    • @GS7999
      @GS7999 4 ปีที่แล้ว

      for loop is executed for every value (i.e i) in "values" and "values" is calling class Topten().
      All the methods inside Topten() will be executed everytime "values" calls the class Topten()

  • @alaapsarkar
    @alaapsarkar 3 ปีที่แล้ว

    print statement prints 1 and the for loop prints 2, 3, 4,..., 10

  • @pratimamaurya8890
    @pratimamaurya8890 3 ปีที่แล้ว

    please make series on python turtle

  • @dhruvchaudhary8054
    @dhruvchaudhary8054 2 ปีที่แล้ว

    sir could you please suggest me a source from where i can practice python, please!!

  • @naingmind5709
    @naingmind5709 2 ปีที่แล้ว

    Finally I got this yayyyyy

  • @msarkar9779
    @msarkar9779 4 ปีที่แล้ว

    what is the use of- values=toptens ?