이 내가 쓴 간단한 계산기이지만 응용 프로그램 를 다시 시작하지 않습니다 마친 후이 내 코드입니다 : 그 나는 그들이 다시 시작 여부를하려는 경우 사용자를 물어보고 싶은 완료python에서 restart 명령을 추가하는 방법은 무엇입니까?
def add(x, y):
return x + y
def subtract(x, y):
return x - y
def multiply(x, y):
return x * y
def divide(x, y):
return x/y
print("Select from the list bellow which oporation you want the calculator to do.")
print("A.Add")
print("S.Subtract")
print("M.Multiply")
print("D.Divide")
choice = input("Enter choice(a/s/m/d):")
if choice != 'a' and choice != 's' and choice != 'm' and choice != 'd':
print (" the letter you intered is not in our lists!")
num1 = int(input("Enter an interger as your first number: "))
num2 = int(input("Enter an integer as second number: "))
if choice == 'a':
print(num1,"+",num2,"=", add(num1,num2))
elif choice == 's':
print(num1,"-",num2,"=", subtract(num1,num2))
elif choice == 'm':
print(num1,"*",num2,"=", multiply(num1,num2))
elif choice == 'd':
print(num1,"/",num2,"=", divide(num1,num2))
else:
print("Invalid input")
input("press enter to close")
. 나는 작동하지 않는 루핑하면서 다른 사용.
우리가 시도한 반복문을 보여 주시면 왜 작동하지 않았는지 이해하도록 도와 드리겠습니다. –
들여 쓰기가 엉망입니다. – thebjorn
* no *'while' 루프가 표시되므로 예상 루프가 작동하지 않는 이유를 알 수 없습니다. – chepner