I have a counter function, counter(), which is supposed to first count to 2 and return one function h() and then continue counting to 3 and return the function g() and break.
def h():
return "hi"
def g():
return "hallo"
def counter():
i = 0
# If i is equal or less than 2, return the function h() and continue
while i <= 2:
i = i +1
return h(),i
continue
# If i equals 3, return function g() and break/end counting
# The current issue with this code is that the function g()
# isn't returned and the condition itself doesn't seem to
# respond, or count up to 3 from 2.
if i == 3:
return g()
return i
print counter()
yieldinstead ofreturn) but it doesn't look like that from the way you call it.print counter()print?