Hello, what am i doing wrong, it

print(“Hello my friend”)

print (“I will be your Calculator”)

print (“Firstly, What would you like to do?”)

choice = raw_input(“Add, Subtract, Multiply or Divide?”)

if choice = (“add”):

it is saying that my last line has an invalid syntax? what have i done wrong

Remember the difference between the asigment operator and comparison operators.

1 Like

I still dont get what you mean? could you give me the correct code?

print(“Hello my friend”)

print (“I will be your Calculator”)

print (“Firstly, What would you like to do?”)

choice = input(str(“Add, Subtract, Multiply or Divide?”))

if choice == (“add”):

addition1 = input(int(“Enter a number you would like to use”))

addition2 = input(int(“Enter the number you would like to add”))

print (addition1 + addition2)

now it is saying this : Traceback (most recent call last): File “python”, line 6, in <module> ValueError: invalid literal for int() with base 10: ‘Enter a number you would like to use’

You must get the input first, then you convert it to int. Otherwise you’re trying to convert the string “Enter a number you would like to use” to int.

int(input("Enter a number you would like to use"))
2 Likes

I bossed it!!!

print(“Hello my friend”)
print (“I will be your Calculator”)
print (“Firstly, What would you like to do?”)
choice = input(str(“Add, Subtract, Multiply or Divide?”))
if choice == (“add”):
addition1 = input("Enter a number you would like to use: ")
addition2 = input("Enter the number you would like to add: ")
print (int(addition1) + int(addition2))
elif choice == (“subtract”):
subtract1 = input("Enter a number you would like to use: ")
subtract2 = input("Enter a number you would like to subtract: ")
print (int(subtract1) - int(subtract2))
elif choice == (“multiply”):
multiply1 = input("Enter a number you would like to use: ")
multiply2 = input("Enter a number you would like to Multiply by: ")
print (int(multiply1) * int(multiply2))
elif choice == input(“divide”):
divide1 = input("Enter a number you would like to use: ")
divide2 = input("Enter a number you would like to divide by: ")
print (int(divide1) / int(divide2))
print (“Thank you for using me today, have a nice week!”)

also, does anyone know how I could prehaps make it a loop to see if they wanted to do another math task