there is a mistake in the assert
assert list(take_only(iter(range(30)),lambda x: x<10 or x%7==0 ,5)) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 14]
while it missed 21 and 28
again fast reading , my false
but it will help others understand, i hope
it stops the generator if it doesnt see n objects in a row that answers the predicate true
i have a problem. when i check the type of a function thet contains "yield" - python says its a function and not a genterator. even if i copy and paste the code from the lecture (infinite natural numbers generator) in idle, it says its a function. not like in the presentation :(
thanks for the help
Well, it's indeed a function, though a function that returns a generator.
Try checking the type(function_name()) instead of type(function_name) - it should be builtins.generator.
how can I "catch" an error? I mean that if I think an error should occur, I want to handle it myself and not be thrown away.
Mainly a general question connected to this assignment:
Why does this happens:
lst=[1,2,3,4,5] >>> a=iter(lst) >>> list(a) [1, 2, 3, 4, 5] >>> list(a) 
I think that after u did list(a), i went over all elements in the iterator, so the next element is probably stopIteration, hence nothing to add for the list ->empty list.
שאלה לגבי סעיף א' - למה בעצם הרשימה אמורה להחזיר את כל האיברים עבורם מודולו 3 נותן 1 (כמו בדוגמה בשרלה ובאסרט), ולא רק את אלו המתקבלים לפני שמתקיים התנאי עבור
I added a function to class Deque, "is_empty". Then I saw an instruction that says it's not allowed to add arguments to the skeleton. should I remove it (and change the code)?