在检查变量是真还是假后,我无法打印消息。我想要做的是从一组变量中打印出真实的变量。必须有比下面更简单的方法,但这就是我能想到的。我需要更好的解决方案或对以下内容进行修改以使其正常工作。
这是我的代码:
if (quirk) and not (minor, creator, nature):
print (quirk, item)
elif (minor) and not (quirk, creator, nature):
print (minor, item)
elif (creator) and not (minor, quirk, nature):
print (creator, item)
elif (nature) and not (minor, quirk, creator):
print (item, nature)
else:
print ("Something went wrong! Properties out of range! Nature =",nature,"Quirk =",quirk,"Minor =",minor,"Creator =",creator)
在这种情况下,我总是得到错误,而从来没有任何打印。该错误始终表明其中一个变量为真。
先感谢您!