[英]Simpel Python Calculator - Syntax Error - Indentation errors
I recently started learning Python.我最近开始学习 Python。 I have never coded before, but it seemed like a challenge.
我以前从未编码过,但这似乎是一个挑战。 The first thing I have made is this calculator.
我做的第一件事就是这个计算器。 However, I can't seem to get it to work.
但是,我似乎无法让它发挥作用。
while True:
print("Typ 'plus' to add two numbers")
print("Typ 'min' to subtract two numbers")
print("Typ 'multiplication' multiply two numbers")
print("Typ 'division' to divide two numbers")
print("Typ 'end' to abort the program")
user_input = input(": ")
if user_input == "end"
break
elif user_input == "plus":
num1 = float(input("Give a number: "))
num2 = float(input("Give another number: "))
result = str(num1 + num2)
print("The anwser is: " + str(result))
elif user_input == "min":
num1 = float(input("Give a number: "))
num2 = float(input("Give another number: "))
result = str(num1 - num2)
print("The anwser is: " + str(result))
elif user_input == "maal":
num1 = float(input("Give a number:"))
num2 = float(input("Give another number: "))
result = str(num1 * num2)
print("The anwser is: " + str(result))
elif user_input == "deel":
num1 = float(input("Give a number: "))
num2 = float(input("Give another number: "))
result = str(num1 + num2)
print("The anwser is: " + str(result))
else:
print ("I don't understand!")
I know it will probably something stupid, I am still very much learning.我知道这可能会很愚蠢,我仍然在学习。 Just trying to pickup a new skill instead of bothering my friends who do know how to code.
只是想学习一项新技能,而不是打扰我知道如何编码的朋友。
You missed a colon after an this if statement在 this if 语句后漏掉了一个冒号
if user_input == "end"
break
Should Be:应该:
if user_input == "end":
break
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.