So I'm a fresh beginner when it comes to coding and here is my first calculator. The "add" function works but instead of actually adding the numbers it just adds the inputs together. For example, if the inputs are 5 and 6 instead of printing 11 it will print out 56. That is my first problem. Second is that I get flashed with this error which is shown at the bottom of the code. Anyone can explain what I'm doing wrong and how to fix it for the future reference?
print("Welcome to my simple calculator")
while True:
print("These are your options")
print("Enter \"add\" to multiply two number together")
print("Enter \"multiply\" to multiply two number together")
print("Enter \"divide\" to multiply two number together")
print("Enter \"subtract\" to multiply two number together")
print("If you are done just type \"quit\"")
user_input = input(":")
if user_input == "quit":
break
elif user_input == "add":
num1 = int(input("Enter the first number :"))
num2 = int(input("Enter the second number"))
result = str(int(num1)*int(num2)
print(f'Your answer: {result}')
elif user_input == "multiply":
num3 = input("Enter the first number :")
num4 = input("Enter the second number")
result = str(num3*num4)
print("Your answer "+result)
elif user_input == "divide":
num5 = input("Enter the first number :")
num6 = input("Enter the second number")
result = str(num5*num6)
print("Your answer "+result)
elif input == "subtract":
num7 = input("Enter the first number :")
num8 = input("Enter the second number")
result = str(num7-num8)
print("Your answer "+result)
I know this is basic. But for a noobie is hard. If you want to post a fixed version of the code please do, I would be very grateful for an explanation of how you got there and what was wrong with my code.
Thanks in advance!