将 for 循环应用于条件语句

Cat*_*aoz -6 python

这是一个示例(来自http://anh.cs.luc.edu/python/hands-on/3.1/handsonHtml/ifstatements.html 的代码片段):

if weight > 50:
    print("There is a $25 charge for luggage that heavy.")
print("Thank you for your business.")
Run Code Online (Sandbox Code Playgroud)

我想把整个代码放在即“for”循环中。使用 for(..){上面的代码在这里}会非常容易。我仍然找不到这样做的方法,我需要编写 for 循环并缩进下面的整个块。我想我在这里遗漏了一些东西......

Mik*_*tty 5

您可以根据需要在 Python 中使用任意数量的括号,尤其是对于您的if语句:

if(( (True) )
   and (1==1) ):
    print("It's really true")
Run Code Online (Sandbox Code Playgroud)

编辑:原始问题已被大量修改,因此此答案可能不再适用于修改后的问题。