goto 只能用在def 裡嗎?
goto 只能用在def 裡嗎?沒用在def就出錯程序代码:
from goto import with_goto @with_goto def range(start, stop): i = start result = [] label .begin if i == stop: goto .end result.append(i) i += 1 goto .begin label .end return result a= range(0,10) print(a)
程序代码:
from goto import with_goto @with_goto i = 0 result = [] label .begin if i == 10: goto .end result.append(i) i += 1 goto .begin label .end print(result)