小编use*_*552的帖子

Python - 简化重复的if语句

我是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"
Run Code Online (Sandbox Code Playgroud)

显然_total和_initial是预定义的.在此先感谢您的帮助.

python if-statement repeat

6
推荐指数
1
解决办法
237
查看次数

标签 统计

if-statement ×1

python ×1

repeat ×1