【发布时间】:2014-05-09 08:40:42
【问题描述】:
我对 python 很陌生,正在寻找一种方法来简化以下内容:
if atotal == ainitial:
print: "The population of A has not changed"
if btotal == binitial:
print: "The population of B has not changed"
if ctotal == cinitial:
print: "The population of C has not changed"
if dtotal == dinitial:
print: "The population of D has not changed"
显然 _total 和 _initial 是预定义的。 提前感谢您的帮助。
【问题讨论】:
-
您好!一个小问题;不要忘记
if语句末尾的冒号。快速内化是件好事。
标签: python if-statement repeat