请输入两个数字和一个字母.如果字母是"a",则数字将被添加,如果"s",则减去,如果"m",则相乘,如果"d",则减去.
这就是我所拥有的:
num1 = int(input("please enter the first number"))
num2 = int(input("please enter the second number"))
lettler = input("please enter the operation")
a = int(num1 + num2)
s = int(num1 - num2)
m = int(num1 * num2)
d = int(num1 / num2)
if lettler + str(a):
print(num1 + num2)
else:
if lettler + str(s):
print(num1 - num2)
else:
if lettler + str(m):
print(num1 * num2)
else:
if lettler + str(d):
print(float(num1) / num2)
Run Code Online (Sandbox Code Playgroud)
但我的教授告诉我这是错的.我该怎么办才能修复它?
python ×1