我正在制作一个计算器,但我希望能够输入希望答案的次数(加,减,乘或除)。因此,我有“ Calc”。这样的输入就是我希望答案发生某些事情的次数。
我尝试做
a = print(tall1 + tall2)
然后将a
设为int
,但这没用
oper = input("What operation: ")
calc = int(input("How many calculations: "))
tall1 = int(input("Type a number: "))
tall2 = int(input("Type another number: "))
if oper == ("+"):
for num in range(calc):
print(tall1 + tall2)
elif oper == ("*"):
print(tall1 * tall2)
elif oper == ("/"):
print(tall1 / tall2)
elif oper == ("-"):
for num in range(calc):
print(tall1 - tall2)
答案 0 :(得分:0)
您拼写错误的1
并在代码末尾添加了额外的`。纠正这两个简单的错误可使代码正确运行:
range()