用于嵌套c++;循环样式 < C++ > /P> for(自动i=min;i。它只在循环中定义。这里可能不需要枚举< /C> >。您要直接迭代范围< /Cord>对象,不枚举范围> /Cord>对象。作为一般指南,不要尝试在Python中编写C++,在Python中编写Python。如果您不更改当你换用另一种语言时,你永远不会真正了解它。 for i in enumerate(range(min, sqrt_max + 1)): for j in enumerate(range(min, i * j < sqrt_max + 1)): for i in range(min, sqrt_max): # i will not take the value of sqrt_max. for j in range(i, 1 + sqrt_max//i): # i is defined here within range, but j is not. ...

用于嵌套c++;循环样式 < C++ > /P> for(自动i=min;i。它只在循环中定义。这里可能不需要枚举< /C> >。您要直接迭代范围< /Cord>对象,不枚举范围> /Cord>对象。作为一般指南,不要尝试在Python中编写C++,在Python中编写Python。如果您不更改当你换用另一种语言时,你永远不会真正了解它。 for i in enumerate(range(min, sqrt_max + 1)): for j in enumerate(range(min, i * j < sqrt_max + 1)): for i in range(min, sqrt_max): # i will not take the value of sqrt_max. for j in range(i, 1 + sqrt_max//i): # i is defined here within range, but j is not. ...,python,python-3.x,iterator,Python,Python 3.x,Iterator,您需要的是以下内容: for i in enumerate(range(min, sqrt_max + 1)): for j in enumerate(range(min, i * j < sqrt_max + 1)): 您在表达式中使用了 j/COD>。它只在循环中定义。这里可能不需要枚举< /C> >。您要直接迭代范围< /Cord>对象,不枚举范围> /Cord>对象。作为一般指南,不要尝试在Python中编写C++,在Python中编写Python。如果您不更改当你换用

您需要的是以下内容:

for i in enumerate(range(min, sqrt_max  + 1)):
    for j in enumerate(range(min, i * j < sqrt_max + 1)):

您在表达式中使用了<代码> j/COD>。它只在循环中定义。这里可能不需要<代码>枚举< /C> >。您要直接迭代<代码>范围< /Cord>对象,不枚举范围> /Cord>对象。作为一般指南,不要尝试在Python中编写C++,在Python中编写Python。如果您不更改当你换用另一种语言时,你永远不会真正了解它。
for i in enumerate(range(min, sqrt_max  + 1)):
    for j in enumerate(range(min, i * j < sqrt_max + 1)):
for i in range(min, sqrt_max):  # i will not take the value of sqrt_max.
    for j in range(i, 1 + sqrt_max//i):  # i is defined here within range, but j is not.
        ...