#61 Python Tutorial for Beginners | Iterator

  Рет қаралды 334,222

Telusko

Telusko

5 жыл бұрын

Github :- github.com/navinreddy20/Python-

Пікірлер: 277
@sohailanwar7536
@sohailanwar7536 3 жыл бұрын
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 жыл бұрын
Thanks 👍
@gokulkrishnayt
@gokulkrishnayt 2 жыл бұрын
Thanks Buddy😊
@atlasatlantis8447
@atlasatlantis8447 Жыл бұрын
I'm pretty sure it's the same for all windows programs. You can even copy youtube comments this way.
@AshiqAli-ie5pm
@AshiqAli-ie5pm 8 ай бұрын
Thanks bro
@sriram9786
@sriram9786 4 жыл бұрын
sir can you put another vedio on this. i dint understand completely.
@Shrishivbharat
@Shrishivbharat 5 жыл бұрын
Sir, when will you make videos on tikinter and other python GUI?
@swethasundaram04
@swethasundaram04 3 жыл бұрын
The raise keyword is used to raise an exception. You can define what kind of error to raise(here its StopIteration).
@shivasaiprasadakula7386
@shivasaiprasadakula7386 2 жыл бұрын
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... 👍🥰
@jimmymesa
@jimmymesa 5 жыл бұрын
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.
@utpalpodder-pk6vq
@utpalpodder-pk6vq 4 жыл бұрын
whether during the creation of the object itself __iter__() method is called just like __init__() method? Is __iter__() method is called only once?
@adilbougma2706
@adilbougma2706 4 жыл бұрын
omg you are a true programmer :D i lauoh so hard when the output print None. i like you debuging method
@ajaybhandari9215
@ajaybhandari9215 4 жыл бұрын
at which point in the video?
@chandrasekar3653
@chandrasekar3653 4 жыл бұрын
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 жыл бұрын
Chandra Sekar how can for loop call next method?
@BryceDoesLife
@BryceDoesLife 4 жыл бұрын
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?
@srushtiagarwal2748
@srushtiagarwal2748 4 жыл бұрын
very interesting and knowledgeable tutorial.👌👍
@anonymous_anonymity
@anonymous_anonymity 4 жыл бұрын
Excellent tutorial 👍👍
@pratikgon522
@pratikgon522 3 жыл бұрын
if I use exit() instead of Raise Iteration then what problem would I face?
@mohamednayeem2602
@mohamednayeem2602 3 ай бұрын
this we can use for interview question but for loop is the best. I haven't used this loop in my entire life
@divyanshusingh6105
@divyanshusingh6105 4 жыл бұрын
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 3 жыл бұрын
What is meant by rattutato
@rayyanamir8560
@rayyanamir8560 2 жыл бұрын
@@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
@rathoreyogendra
@rathoreyogendra 5 жыл бұрын
Sir can you please create video on data structure and algorithm
@harshavardhan.g351
@harshavardhan.g351 4 жыл бұрын
watch jenny lectures for ds and algo
@bhaveshjhawar9532
@bhaveshjhawar9532 2 жыл бұрын
watch code with harry .. thank me later
@schruteman7444
@schruteman7444 2 жыл бұрын
@@bhaveshjhawar9532 thank u
@harshamin7996
@harshamin7996 2 жыл бұрын
Sir, Why can't we use break in else part to stop the execution of for loop ?
@realsumitkumar
@realsumitkumar Жыл бұрын
Break is used only inside a loop
@tanmayisharma5890
@tanmayisharma5890 8 ай бұрын
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()?
@omkarmore7017
@omkarmore7017 4 жыл бұрын
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
@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?
@pinakibhattacharya2761
@pinakibhattacharya2761 4 жыл бұрын
and instead of giving exception in else part can we give break statement at the end of if statement?
@rajeshwardutta
@rajeshwardutta 4 жыл бұрын
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
@zeeshanshahidansari9425
@zeeshanshahidansari9425 3 жыл бұрын
Nice mustache! It suits you Sir. :-)
@shaiksubhan2306
@shaiksubhan2306 4 жыл бұрын
What is going on behind for loop it is good,,,, but what is the use of iterator
@naesone2653
@naesone2653 3 жыл бұрын
wow you really explain well and are one of the few indians that have no accent almost respect
@startjourney8631
@startjourney8631 3 жыл бұрын
Dil se dhanywaad🙏✌️🤗
@ahmetsarkaya9203
@ahmetsarkaya9203 4 жыл бұрын
"try and except" also could be used right? Was there any reason that stopped you to use "try and except" ?
@paulhaso
@paulhaso Жыл бұрын
Excellent video! Thank you
@abhishekroushan9735
@abhishekroushan9735 3 жыл бұрын
is there any way of using variable in place of self.num = 1 means self.num = n and then iterate it for 10 times
@rajkumar-nx1me
@rajkumar-nx1me 4 жыл бұрын
sir what is the advantage of iterator over for loop
@anoshkaniskar1482
@anoshkaniskar1482 3 жыл бұрын
The when you say Iterators. How cool is that..
@muzikizmylyf8411
@muzikizmylyf8411 4 жыл бұрын
I like your learning style
@pradeepmedikonda7282
@pradeepmedikonda7282 5 жыл бұрын
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 жыл бұрын
same queston
@moisesdiaz9852
@moisesdiaz9852 4 жыл бұрын
same question here too
@moisesdiaz9852
@moisesdiaz9852 4 жыл бұрын
I just found it, its because iterators use much less resources than the traditional loop
@sanjaykrish8719
@sanjaykrish8719 4 жыл бұрын
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 жыл бұрын
actually for loop made up of iterator object
@jaikishankumarmore1457
@jaikishankumarmore1457 4 жыл бұрын
Brilliant, thanks a lot!
@bantigarg740
@bantigarg740 3 жыл бұрын
Hey if we have for loop to print 1 to 10 number, why should we use this iterator
@Abhishekkumarsingh-sl5yz
@Abhishekkumarsingh-sl5yz 5 жыл бұрын
sir after class python is becoming difficult any suggestion
@shrihari8886
@shrihari8886 3 жыл бұрын
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
@ursABD
@ursABD 9 ай бұрын
In if condition can we use break to stop the iteration 9:33
@user-pm3ou4dm4w
@user-pm3ou4dm4w 3 жыл бұрын
Thank you Mr. Navin !
@anuragrsimha
@anuragrsimha 4 жыл бұрын
ಸರ್...ನಿಮ್ಮ teaching ನನಗೆ ಬಹಳ ಇಷ್ಟ. ಈ videoಇಂದ ನನ್ನ ಎಲ್ಲಾ doubtಗಳು clear ಆದವು. ಧನ್ಯವಾದಗಳು. సర్...మీరు teaching నాకు చాలా ఇష్టం. ఈ video నుండి నా అన్ని doubtలు clear ఆయింది. ధన్యవాదలు. ಜೈ ಕರ್ನಾಟಕ (జై కర్నాటక)!! ಜೈ ಕನ್ನಡ (జై కన్నడ)!!
@nuqlear1189
@nuqlear1189 11 күн бұрын
kannada pig idli sambhar
@siddharthrautara8811
@siddharthrautara8811 3 жыл бұрын
sir can you let us know a real life example where we use iterator
@Bhabani1994
@Bhabani1994 4 жыл бұрын
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...
@cinemaplus150
@cinemaplus150 4 жыл бұрын
Sir can u make video for machine learning usking sklearn lib for data science
@Engineerincubicle
@Engineerincubicle 5 жыл бұрын
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 3 жыл бұрын
Nothing is free
@ryouko2971
@ryouko2971 5 жыл бұрын
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 жыл бұрын
Bro do u got ur answer please explain me. I'm stuck for days
@narragopichand9982
@narragopichand9982 2 жыл бұрын
If something is returned in a function it return value to function call right ? What is happening to return here. Object is being returned......
@Maks05N
@Maks05N 3 жыл бұрын
It's very funny when you said to NONE iteration "eehh HOLD on"
@mahdi-hasan
@mahdi-hasan Жыл бұрын
If you want to work the loop for multiple times put "self.num = 1" in else condition.
@pawnage3
@pawnage3 2 жыл бұрын
Thank you Mr. Reddy!
@malakhassan9816
@malakhassan9816 Ай бұрын
How we typed self.num and we hadn't typed method named num or class nemed num?..num is not defined..
@sheikwaris
@sheikwaris 4 жыл бұрын
Navin, pls stat what is the purpose of __iter__ method at all
@rakeshmali1727
@rakeshmali1727 4 ай бұрын
at 5:11, why did the for loop print 7 and 8 again? this contradicts with 10:22 no?
@naufilibrahimmukadam7023
@naufilibrahimmukadam7023 5 жыл бұрын
Sir, Pune MeetUp when....???
@shubhamvashisth2886
@shubhamvashisth2886 3 жыл бұрын
since we already have for loop to iterate the list then why are we making things more complex by making this iterator
@pramitharyan5167
@pramitharyan5167 4 жыл бұрын
one more video on iterator please
@hamzabohra3267
@hamzabohra3267 3 жыл бұрын
sir why are we using raise ? can we not use break
@dhruvchaudhary8054
@dhruvchaudhary8054 2 жыл бұрын
sir could you please suggest me a source from where i can practice python, please!!
@keerthichowdary750
@keerthichowdary750 3 жыл бұрын
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 2 жыл бұрын
have you cleared that doubt ? if yes please explain
@msarkar9779
@msarkar9779 3 жыл бұрын
what is the use of- values=toptens ?
@RamKaruna-em3xh
@RamKaruna-em3xh 2 ай бұрын
Sir other way to stop the loop is self.num=self.num+0 , is this right sir
@prsh1989
@prsh1989 4 жыл бұрын
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 3 ай бұрын
@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
@palanitpt
@palanitpt 5 жыл бұрын
Thank you
@venkatratnam4891
@venkatratnam4891 3 жыл бұрын
after a long time i have seen your mustache
@haaahaaa8396
@haaahaaa8396 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"
@zuberkhan-kn7iu
@zuberkhan-kn7iu 3 жыл бұрын
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.
@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
@dnyaneshwarkadam6823
@dnyaneshwarkadam6823 5 жыл бұрын
Thanks 😊....
@sivasaran4
@sivasaran4 3 жыл бұрын
can we use break instead of "raise stop iteration"
@virtualmagic5489
@virtualmagic5489 3 жыл бұрын
same doubt
@karthikreddy4430
@karthikreddy4430 3 жыл бұрын
@@virtualmagic5489 break can only be used in for loop and switch i guess
@PawanKumar-cm6lg
@PawanKumar-cm6lg 3 жыл бұрын
'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 2 жыл бұрын
nope
@054_ritesh3
@054_ritesh3 3 жыл бұрын
Good sir ji👍👍👍
@sagarr1640
@sagarr1640 2 жыл бұрын
By this way are v overloading the Iter & next inbuilt function ?
@siddharthmishra8233
@siddharthmishra8233 2 жыл бұрын
yes sort of.
@Rajadahana
@Rajadahana 2 жыл бұрын
If you type print(next(values)) after the for loop, you will get an Error.
@divyanshijaiswal8500
@divyanshijaiswal8500 4 жыл бұрын
Sir, please make on video of game development and app development.
@EruditeGaming
@EruditeGaming 3 жыл бұрын
Sir, can we use limiter in __next__
@srilakshmi4620
@srilakshmi4620 4 жыл бұрын
how to goto previous element in interator?
@yashsalvi6850
@yashsalvi6850 4 жыл бұрын
Can someone help me know that what happens after "for i in values " is called ?
@rahulkalgutkar6983
@rahulkalgutkar6983 3 жыл бұрын
__iter__() is called and then __iter__() calls __next__(). __next__() runs till the exception is raised.
@guru_bro
@guru_bro 3 жыл бұрын
@@rahulkalgutkar6983 can u elaborate on this please maybe on insta
@HelloHey12
@HelloHey12 4 жыл бұрын
Sir what if want user input??
@harshgupta9761
@harshgupta9761 4 жыл бұрын
Why only return self is use under iter block
@kamalpathak4065
@kamalpathak4065 3 жыл бұрын
So why we use loop if we have iterators
@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
@utkarshsoni7938
@utkarshsoni7938 5 жыл бұрын
First view! For the first time.
@virtualmagic5489
@virtualmagic5489 3 жыл бұрын
What does that __iter__() method do here sir
@prachinainawa3055
@prachinainawa3055 4 жыл бұрын
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.
@zuberkhan-kn7iu
@zuberkhan-kn7iu 3 жыл бұрын
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
@zuberkhan-kn7iu
@zuberkhan-kn7iu 3 жыл бұрын
@@guru_bro Where?
@guru_bro
@guru_bro 3 жыл бұрын
@@zuberkhan-kn7iu what does iter Dunder method do and y it returns self what is the use of returning same object which is passed?
@ankuragarwal4014
@ankuragarwal4014 4 жыл бұрын
sir how to do text parsing in python?
@naingmind5709
@naingmind5709 2 жыл бұрын
Finally I got this yayyyyy
@sepehrtavakoli591
@sepehrtavakoli591 8 ай бұрын
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
@pratimamaurya8890
@pratimamaurya8890 3 жыл бұрын
please make series on python turtle
@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???
@TheProgrammingJourney
@TheProgrammingJourney 3 жыл бұрын
Bcoz it is initialised same as __init__
@prashantkumargautam4191
@prashantkumargautam4191 3 жыл бұрын
It will print 1 or 11?
@himanshumangal483
@himanshumangal483 4 жыл бұрын
Nice!
@avert_
@avert_ 4 жыл бұрын
what is the use of __init__(self)? why cant we simply use val and increment values to it?
@telugutravellerraj
@telugutravellerraj 4 жыл бұрын
__init__ is to initialize the variable, here 'num'.
@komaljoshi2272
@komaljoshi2272 5 жыл бұрын
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
@zuberkhan-kn7iu
@zuberkhan-kn7iu 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
@vikaspal2799
@vikaspal2799 3 жыл бұрын
Why do we need the iter() method while defining our own iterator???
@user-rn6zc7vp3h
@user-rn6zc7vp3h 2 жыл бұрын
Yeah no need of iter if our class have next method and we are not even calling iter
@dobbysurfs
@dobbysurfs 8 ай бұрын
You are making your object an iterator ,next method can only be used if there is an iterator.
@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 ?
@banti000
@banti000 5 жыл бұрын
Iter is linked to next , how and what it's doing,(return self) !
@harshavardhandsh5190
@harshavardhandsh5190 5 жыл бұрын
I could not understand the benefits of iterator over cute for loop
@aldrinsaurovsarker5159
@aldrinsaurovsarker5159 3 жыл бұрын
@@harshavardhandsh5190 used in data structures
@tanaysamanta4730
@tanaysamanta4730 2 жыл бұрын
def __iter__(self): return self What is the reason of using it? Can anyone explain?
@veeramallabhoomika3435
@veeramallabhoomika3435 3 жыл бұрын
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)
@khasimvali3303
@khasimvali3303 4 жыл бұрын
Can we use break instead of raising exception?
@AngryCheerio
@AngryCheerio 2 жыл бұрын
dont think so
@akashgandhi7886
@akashgandhi7886 4 жыл бұрын
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.
@volundthe_smith7623
@volundthe_smith7623 Жыл бұрын
Good
@arkeys8764
@arkeys8764 3 жыл бұрын
Where are we calling next function in for loop and without calling it how the value are printing??
@GS7999
@GS7999 3 жыл бұрын
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()
@saitangudu3650
@saitangudu3650 4 жыл бұрын
Can u please tell the time complexity for the iterators
@AngryCheerio
@AngryCheerio 2 жыл бұрын
nah
#62 Python Tutorial for Beginners | Generators
6:11
Telusko
Рет қаралды 298 М.
#63 Python Tutorial for Beginners | Exception Handling
15:59
Telusko
Рет қаралды 494 М.
Each found a feeling.#Short #Officer Rabbit #angel
00:17
兔子警官
Рет қаралды 4,2 МЛН
Abstract Class and Abstract Method in Python
12:29
Telusko
Рет қаралды 346 М.
Iterators vs. Generators in Python : Data Science Code
12:37
ritvikmath
Рет қаралды 17 М.
Python Generators Explained
28:37
Tech With Tim
Рет қаралды 144 М.
Stop Making Clones while Learning Programming
6:09
Telusko
Рет қаралды 58 М.
6 Tips to write BETTER For Loops in Python
9:19
Patrick Loeber
Рет қаралды 245 М.
Mi primera placa con dios
0:12
Eyal mewing
Рет қаралды 689 М.
Хотела заскамить на Айфон!😱📱(@gertieinar)
0:21
Взрывная История
Рет қаралды 106 М.
Carregando telefone com carregador cortado
1:01
Andcarli
Рет қаралды 2,5 МЛН
cool watercooled mobile phone radiator #tech #cooler #ytfeed
0:14
Stark Edition
Рет қаралды 9 МЛН