5 Answers
+ 3
# Could be an indentation error
def evens(max):
v = 0
while v <= max:
yield v
v+=2
0
Btw: Question was to put the missing word where yield was which i did, but the code comes up with a syntax error
0
Lisa Thank you!
def evens(max):
v = 0
while v <= max:
yield v
v+=2
if v >= 300:
break
print(evens(max))
This now outputs but not what i expected
0
What did you expect? In case you wanted a list, you would need to wrap it in list():
print(list(evens(10)))
Here's a little demonstration of how evens() could be used:
https://code.sololearn.com/cPsN1TsMB070/?ref=app
0
Lisa i expected to get a result similar to # generator one that is on your code above.
But for some reason this was the result i got with my code:
<generator object evens at 0x7f10722723c0>
P.s. Thank you, you are very helpful!