I’m trying to write a procedure for a baseball program that will use multiple generators to get strikes and balls. My generators look like this:
k = (strike(x) for x in range(3) if x%1 ==0)
w = (ball(n) for n in range(4) if x%1 == 0)
The procedure that I have so far looks like this:
def count(pitch):
if pitch == 'strike':
return next(k),w
elif pitch =='ball':
return next(w),k
I would like my code to return the next results for strike and also return the current for balls, And vice versa. Please help I’m pretty stumped.
An easier way to do this :
output: