+ 2
Can someone pls explain me these codes?
8 Respuestas
+ 6
HonFu
after yield the programm returns the value.
it is first the inner yield... it is evaluated first
and after the outer one.. which evaluated to None.
so... yes...
+ 6
You have generator functions there.
Whenever you call them, you get a generator object, that follows the code of the function body, usually handing out values one by one (in this case only one).
* just unpacks any iterable, also generator objects, in one run, so that you can for example - as done here - print them out one by one.
You should read/repeat the tutorial lesson about generators.
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2462/
+ 2
very tricky
* makes the music
it makes the generator iterate.
without it only generator object is yielded/returned.
0
HonFu i mean yield (yield 5)
so the yield 5 gives a generator and now yield (generator) gives None but when in another case the generator is yielding 4 when yielding the value
0
Hm.
Is yield (yield 5) synonymous with this?
yield 5
yield
0
HonFu Oma Falk
in code 1
yield (yield 5) how it will be processed
if yield 5 in bracket is processed than the o/p will be a generator object stored somewhere so now as the yield 5 is giving generator object and which is followed by another yield function so now yield (generator) generator is the o/p of yield 5 than it is giving None
but in code 2
star() is yielding a generator object too
which in another function is followed by another yield (generator_object) o/p of star function but the o/p in both the case are different one is giving 4 and another is giving None while processing 2nd yield
0
sorry not 4 but giving generator objects location