The raise keyword is used to raise an exception. You can define what kind of error to raise(here its StopIteration).
@shivasaiprasadakula73863 жыл бұрын
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... 👍🥰
@sriram97864 жыл бұрын
sir can you put another vedio on this. i dint understand completely.
@BryceDoesLife5 жыл бұрын
This was exactly what I needed thank you
@bhu18683 жыл бұрын
seems like you are an music artist, do u use python in music some way?
@mohammadziauddin6270 Жыл бұрын
There was an indentation error at return val thats why its repeating., remove 1 space before return.
@prsh19895 жыл бұрын
why we use iterator? I mean if we have for loop, then why iterator? Any real world programming example where this is used?
@sheikwaris4 жыл бұрын
have same question
@naveensai40396 ай бұрын
@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
@malakhassan98165 ай бұрын
How we typed self.num and we hadn't typed method named num or class nemed num?..num is not defined..
@telugu_rockzzАй бұрын
It is not a parameter it just initialised
@Shrishivbharat5 жыл бұрын
Sir, when will you make videos on tikinter and other python GUI?
@sohailanwar75363 жыл бұрын
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).
@mehulsharma73332 жыл бұрын
Thanks 👍
@gokulkrishnayt2 жыл бұрын
Thanks Buddy😊
@atlasatlantis8447 Жыл бұрын
I'm pretty sure it's the same for all windows programs. You can even copy youtube comments this way.
@AshiqAli-ie5pm Жыл бұрын
Thanks bro
@adilbougma27064 жыл бұрын
omg you are a true programmer :D i lauoh so hard when the output print None. i like you debuging method
@ajaybhandari92154 жыл бұрын
at which point in the video?
@Someone-kw6mw4 жыл бұрын
binod bonod
@harshamin79962 жыл бұрын
Sir, Why can't we use break in else part to stop the execution of for loop ?
@realsumitkumar2 жыл бұрын
Break is used only inside a loop
@HackingWithCoffee5 жыл бұрын
Sir can you please create video on data structure and algorithm
@harshavardhan.g3514 жыл бұрын
watch jenny lectures for ds and algo
@bhaveshjhawar95323 жыл бұрын
watch code with harry .. thank me later
@schruteman74442 жыл бұрын
@@bhaveshjhawar9532 thank u
@utpalpodder-pk6vq4 жыл бұрын
whether during the creation of the object itself __iter__() method is called just like __init__() method? Is __iter__() method is called only once?
@pinakibhattacharya27614 жыл бұрын
and instead of giving exception in else part can we give break statement at the end of if statement?
@rajeshwardutta4 жыл бұрын
I don't think you could. Break works for loops, but IF is a conditional operator.
@puneet87054 жыл бұрын
not break but breakpoint will work
@addagallanaresh40443 жыл бұрын
@@rajeshwardutta switch is also conditional entry but it supports break..its not a loop
@sivasaran43 жыл бұрын
can we use break instead of "raise stop iteration"
@virtualmagic54893 жыл бұрын
same doubt
@karthikreddy44303 жыл бұрын
@@virtualmagic5489 break can only be used in for loop and switch i guess
@pradeepmedikonda72825 жыл бұрын
What is the use of iterator while we have a for loop and we can go for a every element of the list....
@adnanfaisal10854 жыл бұрын
same queston
@moisesdiaz98524 жыл бұрын
same question here too
@moisesdiaz98524 жыл бұрын
I just found it, its because iterators use much less resources than the traditional loop
@sanjaykrish87194 жыл бұрын
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
@bmanicharanreddy73864 жыл бұрын
actually for loop made up of iterator object
@jimmymesa5 жыл бұрын
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.
@xtonx-theofficialbeechslay15752 жыл бұрын
i geniunly have a hatred toward people using light mode
@komaljoshi22725 жыл бұрын
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?
@anujdahiya3415 жыл бұрын
i'm in somewhat same situation
@OasisFinder3 жыл бұрын
Python is booming in terms of job in 2020. even if you are not from IT learn this , take your time and you can
@divyanshusingh61054 жыл бұрын
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
@balla40044 жыл бұрын
What is meant by rattutato
@rayyanamir85603 жыл бұрын
@@balla4004 He means rattu tota.
@amalayakin44112 жыл бұрын
Our college also the same scenarios happens
@vishutanwar2 жыл бұрын
@@balla4004 means they just make student memorise programing
@zeeshanshahidansari94254 жыл бұрын
Nice mustache! It suits you Sir. :-)
@shrihari88864 жыл бұрын
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
@omkarmore70174 жыл бұрын
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
@akashgandhi78864 жыл бұрын
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
@HassanRahamathullah3 жыл бұрын
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.
@shaiksubhan23065 жыл бұрын
What is going on behind for loop it is good,,,, but what is the use of iterator
@banti0005 жыл бұрын
Iter is linked to next , how and what it's doing,(return self) !
@harshavardhandsh51905 жыл бұрын
I could not understand the benefits of iterator over cute for loop
@aldrinsaurovsarker51594 жыл бұрын
@@harshavardhandsh5190 used in data structures
@sagarr16403 жыл бұрын
By this way are v overloading the Iter & next inbuilt function ?
@siddharthmishra82332 жыл бұрын
yes sort of.
@mrvilgax1183 Жыл бұрын
how many of you went back video and see he have mustache(search meaning in google) of our teacher 😂🤣🤣
@ursABD Жыл бұрын
In if condition can we use break to stop the iteration 9:33
@Engineerincubicle5 жыл бұрын
Sir, My Final Year Project is on Virtual Mouse using Hand gestures using OpenCV and Python,Can you please help me in this,Sir?
@merowe1234 жыл бұрын
Nothing is free
@siddharthrautara88114 жыл бұрын
sir can you let us know a real life example where we use iterator
@pothalasiva48204 жыл бұрын
Sir why can't we use break statement 🤔🤔
@prakharprakashverma24094 жыл бұрын
bcoz break keyword is used to break loops but here if condition is used
@zakiasmaa6834Ай бұрын
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 !!!
@sakthivadivel10573 жыл бұрын
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 ?
@cinemaplus1504 жыл бұрын
Sir can u make video for machine learning usking sklearn lib for data science
@naesone26533 жыл бұрын
wow you really explain well and are one of the few indians that have no accent almost respect
@ryouko29715 жыл бұрын
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_bro3 жыл бұрын
Bro do u got ur answer please explain me. I'm stuck for days
@30.ayushyadav41Ай бұрын
instead of for why we don't use while i
@haaahaaa83964 жыл бұрын
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
@mohammadmohsinmohammedmohs97174 жыл бұрын
Even I am second year student, can you tell whether you are understanding oops concepts?? I'm not able to get it
@hxrsh_x3 жыл бұрын
@@mohammadmohsinmohammedmohs9717 seach for "Corey Schafer OOPs tutorial in Python"
@OasisFinder3 жыл бұрын
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.
@amritanshusinghbhumihar2 жыл бұрын
Experience.
@dobbysurfs Жыл бұрын
Im sorry to say your explanation is becoming staler and actually complicates the concepts,for the last 3 videos including this one .i had to go to another video and learn it and comeback here.i hope i don't have to do that every video from now on
@keerthichowdary7504 жыл бұрын
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......
@dhamoramesh82103 жыл бұрын
have you cleared that doubt ? if yes please explain
@vikaspal27993 жыл бұрын
Why do we need the iter() method while defining our own iterator???
@user-rn6zc7vp3h3 жыл бұрын
Yeah no need of iter if our class have next method and we are not even calling iter
@dobbysurfs Жыл бұрын
You are making your object an iterator ,next method can only be used if there is an iterator.
@santhoshbyri1254 жыл бұрын
break also possible
@arifurbhuyan83729 ай бұрын
not sure why this particular lecture was needed :( .. was very confusing
@RamKaruna-em3xh6 ай бұрын
Sir other way to stop the loop is self.num=self.num+0 , is this right sir
@tanaysamanta47303 жыл бұрын
def __iter__(self): return self What is the reason of using it? Can anyone explain?
@yashsalvi68504 жыл бұрын
Can someone help me know that what happens after "for i in values " is called ?
@ContentArm4 жыл бұрын
__iter__() is called and then __iter__() calls __next__(). __next__() runs till the exception is raised.
@guru_bro3 жыл бұрын
@@ContentArm can u elaborate on this please maybe on insta
@farazahmed16685 жыл бұрын
Hello sir, love from Pakistan...!
@ITSkillswithSurajDatir3 жыл бұрын
looking handsome
@chandrasekar36535 жыл бұрын
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.
@nithinsamudrala96974 жыл бұрын
Chandra Sekar how can for loop call next method?
@shivangigoel91705 жыл бұрын
class TOPT: def __int__(self): self.num=1 def __iter__(self): return self def __next__(self): if self.num
@shivangigoel91705 жыл бұрын
@Leonardo cool thanks
@chandusree32485 жыл бұрын
That is --init-- not --int--
@subasrim9624 жыл бұрын
Your mistakes for loop...for I in values Print (i)
@prachinainawa30555 жыл бұрын
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.
@OasisFinder3 жыл бұрын
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_bro3 жыл бұрын
Can u help for one doubt please I'm stuck for days
@OasisFinder3 жыл бұрын
@@guru_bro Where?
@guru_bro3 жыл бұрын
@@OasisFinder what does iter Dunder method do and y it returns self what is the use of returning same object which is passed?
@sepehrtavakoli59111 ай бұрын
It prints 1to10 but if we remove for loop it will give you only one
@mayankrajput28892 ай бұрын
Can we say we are using method overloading here?
@sowmya60053 жыл бұрын
why even without calling iter and next methods they are running
@KoreanPanda3 жыл бұрын
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?
@onnlyfutebol3 жыл бұрын
I still can't seem to comprehend the word iterate, aswell when he says it 'loops' over. I would really appreciate if anyone could dumb down the explanation as much as possible I'm desperate to understand this concept lol. Thank you in advance
@rajkumar-nx1me5 жыл бұрын
sir what is the advantage of iterator over for loop
@narragopichand99823 жыл бұрын
If something is returned in a function it return value to function call right ? What is happening to return here. Object is being returned......
@p.l.ramakrishna40152 жыл бұрын
we are hearing to learn, not checking your talent.
@bharathkumar58704 жыл бұрын
list is already an iterator.why making it iterator again
@hassnainamjad10593 жыл бұрын
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
@pramitharyan51674 жыл бұрын
one more video on iterator please
@AbdulKalamchessebank4 жыл бұрын
Complex program...😥
@Abhishekkumarsingh-sl5yz5 жыл бұрын
sir after class python is becoming difficult any suggestion
@mounikak38184 жыл бұрын
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
@ElyasSAhmad4 жыл бұрын
class iterator: def __init__(self): self.a = 0 def __iter__(self): return self def __str__(self): return '{}'.format(self.a) def __next__(self): if self.a
@rakeshmali17278 ай бұрын
at 5:11, why did the for loop print 7 and 8 again? this contradicts with 10:22 no?
@Shubhamfoodshorts3 жыл бұрын
since we already have for loop to iterate the list then why are we making things more complex by making this iterator
@iamniks4 жыл бұрын
sir i have a question Why u used " raise StopIteration " ? why not u use " Break " instead ??? please explain anyone
@OasisFinder3 жыл бұрын
break works on LOOPs "for" or "while" not conditions like "if"
@mohamednayeem26027 ай бұрын
this we can use for interview question but for loop is the best. I haven't used this loop in my entire life
@virtualmagic54893 жыл бұрын
What does that __iter__() method do here sir
@vanshikasharma4813 жыл бұрын
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
@vanshikasharma4813 жыл бұрын
help me with this pls
@saicharan46694 жыл бұрын
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
@dragonwarrior74425 жыл бұрын
class Habit(Str): pass print(Habit("yellow")) O/p :. Yellow How it works internal Plzzz sir it's important for me
@placement36085 жыл бұрын
It's so simple bro
@placement36085 жыл бұрын
Pass used so it will skip that part
@telugutravellerraj5 жыл бұрын
It gives error "NameError: name 'Str' is not defined". How did you get output 'Yellow' ?
@paristar30794 жыл бұрын
@@telugutravellerraj You first have to define a class named Str and define init method which takes in a string ... Remember the case sensitivity And it still won't output yellow ... It will print the object itself
@srushtiagarwal27485 жыл бұрын
very interesting and knowledgeable tutorial.👌👍
@KeremAli-cm3pj2 ай бұрын
Also very interesting mustache (❁´◡`❁)(●'◡'●)
@pratimamaurya88903 жыл бұрын
please make series on python turtle
@alaapsarkar3 жыл бұрын
print statement prints 1 and the for loop prints 2, 3, 4,..., 10
@nilimasharma68492 ай бұрын
Instead of raise stop iteration can't we just use a break statement after else
@telugu_rockzzАй бұрын
No we can't use it
@desiandhomemade4 жыл бұрын
it should not print the value "1" again because now value pointer has moved to next which is "2"
@bantigarg7404 жыл бұрын
Hey if we have for loop to print 1 to 10 number, why should we use this iterator
@tanmayisharma5890 Жыл бұрын
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()?
@ankitchetri29683 жыл бұрын
To be honest i understood this better from u sir in comparison to code with harry ,i m not comparing but actually u r a little better in explaining , don't kill me code with harry fans i am also his fan it's just my opinion
@muzikizmylyf84115 жыл бұрын
I like your learning style
@ahababbinhabibosama25652 жыл бұрын
I like your moustache
@startjourney86313 жыл бұрын
Dil se dhanywaad🙏✌️🤗
@squadslayer94683 жыл бұрын
It will give all ten value once
@Rajadahana2 жыл бұрын
If you type print(next(values)) after the for loop, you will get an Error.
@hxrsh_x3 жыл бұрын
Sir, mere palle kuch bhi nahi pad raha hai
@Bhabani19945 жыл бұрын
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...
@sheikwaris4 жыл бұрын
Navin, pls stat what is the purpose of __iter__ method at all
@dhruvchaudhary80543 жыл бұрын
sir could you please suggest me a source from where i can practice python, please!!