import sys
import os
print ("Welcome to the Calculator")
def main():
a = input ("Please enter the first operand: ")
op = input ("Please enter the operation you wish to perform, +, -, *, / : ")
b = input ("Please enter the second operand: ")
a = int(a)
b = int(b)
if op == "+":
ans = (a + b)
print (ans)
elif op == "-":
ans = (a - b)
print (ans)
if op == "*":
ans = (a * b)
print (ans)
elif op == "/":
ans = (a / b)
print (ans)
again = input("Would you like to perform another calculation? Y or N?")
if again == "Y":
main()
main()
Hi, sorry for asking so many questions.
Basically, I put my code above, and upon executing the code by double clicking the .py file, which launches it off CMD, after being prompted with the message: "Please enter the operation you wish to perform, +, -, *, / :"
CMD just randomly closes itself. It's also happened to all my Python programs. Any ideas why? Is it to do with my terrible code?
All replies are much appreciated :)