所以,我一直在研究代码,但我遇到了一个问题。我会得到一个无效的语法。我该如何解决这个问题?
print ("Ok, type away")
number1 = input("Input the first number \n")
symbol = input("Input your desired operation (+,-,*,/) \n")
number2 = input("Input the second number \n")
if symbol == "+":
output = (int(number1) + int(number2))
elif symbol == "-":
output = (int(number1) - int(number2))
elif symbol == "*":
output = (int(number1) * int(number2))
elif symbol == "/":
output = (int(number1) / int(number2))
else:
print ("Something went wrong, ty again")
number1 = input("Input the first number \n")
symbol = input("Input your desired operation (+,-,*,/) \n")
number2 = input("Input the second number \n")
if symbol == "+":
output = (int(number1) + int(number2))
elif symbol == "-":
output = (int(number1) - int(number2))
elif symbol == "*":
output = (int(number1) * int(number2))
elif symbol == "/":
output = (int(number1) / int(number2))
print ("I'm thinking, Please be Patient")
time.sleep ((random.randint(2,9))
print ((output))
注意:这是最后一次打印。
答案 0 :(得分:1)
最后一个print
之前的行有不平衡的括号。