大佬们 辅助一下小弟
def putNumbers(n):i = 0
while i<n:
j=i
i=i+1
if j%7==0:
yield j
for i in reverse(100):
print (i)
错误:
for i in reverse(100):
NameError: name 'reverse' is not defined
请大佬指点 ???
不应该是for i in putNumber(100):吗? def putNumbers(n):
i = 0
while i<n:
j=i
i=i+1
if j%7==0:
yield j
for i inputNumbers(100):
print (i)
reverse是个啥?
你没定义的话,python也不知道啊。 heidern0612 发表于 2020-5-21 09:27
reverse是个啥?
你没定义的话,python也不知道啊。
大佬 我该怎么定义 {:5_104:} qiuyouzhi 发表于 2020-5-21 09:24
???
不应该是for i in putNumber(100):吗?
Define a class with a generator which can iterate the numbers, which are divisible by 7, between a given range 0 and n. 题目是这样的大佬 Justheartyoung 发表于 2020-5-21 09:39
大佬 我该怎么定义
赋值操作不就定义了么?… Justheartyoung 发表于 2020-5-21 09:40
Define a class with a generator which can iterate the numbers, which are divisible by 7, between a ...
不是
你那个reverse是哪里来的? 你是要这样子吧:
def putNumbers(n):
i = 0
while i<n:
j=i
i=i+1
if j%7==0:
yield j
reverse = putNumbers(100)
for i in reverse:
print (i)
reverse怎么来的?这个没有定义啊! heidern0612 发表于 2020-5-21 09:41
赋值操作不就定义了么?…
谢谢 但是为什么不能打印出来i
只显示运行成功Process finished with exit code 0
页:
[1]