我有一个简单的疑问。
我可以编写以下if语句条件!: 如果是,在我运行代码时,它显示在下面的错误中。
sword_check = sword_charge >= 0.90
shield_check = shield_energy >= 100
if sword_check and shield_check:
print("The dragon crumples in a heap. You rescue the gorgeous princess!")
else:
print("Your attack has no effect, the dragon fries you to a crisp!")
NameError Traceback (most recent call last)
<ipython-input-19-40fda14a16d7> in <module>
----> 1 word_check = sword_charge >= 0.90
2 shield_check = shield_energy >= 100
3
4 if sword_check and shield_check:
5 print("The dragon crumples in a heap. You rescue the gorgeous princess!")
NameError: name 'sword_charge' is not defined
答案 0 :(得分:1)
是的,您可以编写一个if语句。错误来自注释中提到的错字。
答案 1 :(得分:1)
您想首先清楚地定义所有变量,然后可以执行两个if语句来确定sword_check和/或shield_check虚拟变量是否应等于1。下面的代码应该使您入门。
[{'key 1': ['apple', 'orange']},
{'key 2': ['oreo', 'chips']}]