'Can someone explain to me what is happening in this python code?
def stringParser():
while True:
name = yield
(fname, lname) = name.split()
f.send(fname)
f.send(lname)
def stringLength():
while True:
string = yield
print("Length of '{}' : {}".format(string, len(string)))
f = stringLength(); next(f)
s = stringParser()
next(s)
s.send('Jack Black')
And how did we get the output as
Length of 'Jack' : 4
Length of 'Black' : 5
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
