“高级”计算器失败

时间:2019-03-23 12:17:03

标签: python python-3.x

我正在制作一个计算器,但我希望能够输入希望答案的次数(加,减,乘或除)。因此,我有“ 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)

1 个答案:

答案 0 :(得分:0)

您拼写错误的1并在代码末尾添加了额外的`。纠正这两个简单的错误可使代码正确运行:

range()