【发布时间】:2020-08-02 18:40:36
【问题描述】:
我正在制作一个只执行一定数量的操作的计算器,如果输入了其他任何内容,它会打印一条提醒消息。 但是在该过程中,在打印'a'之后会发生名称错误。 我哪里错了?
if Operation == '+':
c = a + b
elif Operation == '-':
c = a - b
elif Operation == '*':
c = a * b
elif Operation == '/':
c = a / b
else:
print('Read the Instructions again, dimmwit')
print('Your answer is', c)
print('Thanks! Have a great time!')
请就我应该如何改进我的代码提出一些建议。
【问题讨论】:
标签: python if-statement calculator nameerror