We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Debugging
- Default Arguments
- Discussions
Default Arguments
Default Arguments
Sort by
recency
|
195 Discussions
|
Please Login in order to post a comment
Why does the problem say "the task is to debug the existing code" when there is no existing code at all?
I am extremely cconfused by the problem saying "the task is to debug the existing code". It makes me think I don't need to define OddStream etc. myself. Why not just say define your own OddStream, EvenStream etc. and produce expected output???
It work perfect after adding stream.init() to reset current variable.
def print_from_stream(n, stream=EvenStream()):
def print_from_stream(n, stream=EvenStream()): stream.init() #initialize the current variable in the EvenStream() for _ in range(n): print(stream.get_next())
This part in the explanation is extremely misleading, Makes you think current should be 2 instead of 0 for even.
"In the second query, the function print_from_stream(3) is exectuted, which leads to printing values 2,4 and 6 in separated lines as the first three non-negative even numbers."