# Program did not run correctly

## Recommended Posts

Hello everyone! I was watching kjdElectronics youtube videos and was looking at his tutorial 7 video. And I was following his coding until this part of the video where he managed to get his calculator program working. But when I try to do it myself, the program did not work as it should. Here are my codings:

```def add(num1, num2):
return num1 + num2

def sub(num1, num2):
return num1 - num2

def mul(num1, num2):
return num1 * num2

def div(num1, num2):
try:
return num1 / num2
except ZeroDivisionError:
print("Error, you cannot divide by zero")

def main():
user_continue = True
while user_continue:
validInput = False
while not validInput:
try:
myName = input("What is your name?")
print("Hello")
print(myName)
num1 = int(input("Enter num1:"))
num2 = int(input("Enter num2:"))
operation = input("What do you want to do?(1.addition, 2.subtraction, 3.multiply, 4.division)")
validInput = True
except:
print ("Invalid Command, please try again!")
if (operation == '1'):
elif (operation == '2'):
print(sub(num1,num2))
elif (operation == '3'):
print(mul(num1, num2))
elif (operation == '4'):
print(div(num1, num2))
else:
print("Invalid")

user_yn = input('Would you like to run another calculation? (Y/N)')
if (user_yn != 'Y'):
user_continue = False
break
else:
continue```

And when I run it, I got this:

Process finished with exit code 0

Rather than asking me to input my name or num1 and num2. Can anyone help me spot any error in my codings? That will be greatly appreciated! Thanks in advance:)

##### Share on other sites

See my response in earlier. It is the Same issue.

##### Share on other sites
37 minutes ago, Kevin said:

See my response in earlier. It is the Same issue.

I see, i forget to include the "main()" at the end of the coding. Thank you :)

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.