【发布时间】:2015-02-09 11:39:13
【问题描述】:
我知道我的会看起来微不足道,但我无法弄清楚为什么“停止”不等于零,因为“开始”值已经被覆盖。但是当我从函数中模拟相同的场景时,它确实如此覆盖它。我在这里遗漏了什么吗?
def interval(start, stop =None, step = 1 ):
'Imitates range() for step >0 '
if stop is None:
start, stop = 0, start #since start is already 0, why isn't stop as well?
print start,stop , step
result = []
i = start
while i< stop:
result.append(i)
i+=step
return result
【问题讨论】: