Forums

basic if statements

I'm trying to code a basic if statement but am getting a syntax error, highlighting the "=" sign in the my second row:

i = input("please enter your ingredients")
if (i = "tuna"):
    print("you can make tuna pasta bake")
elif (i = "sausages"):
    print ("you can make sausage and mash")
else:
    print("no recipes contain this ingredients")

You are asking if two things are equal, use the double-equal sign:

if(i=="tuna"):
    print("you can make tuna pasta bake")

The single equals sign is for assigning a value, the double-equals sign checks if two things are equal.

You also don't need the brackets after the if statement in Python, so you can do this:

i = input("please enter your ingredients")
if i == "tuna":
    print("you can make tuna pasta bake")
elif i == "sausages":
    print ("you can make sausage and mash")
else:
    print("no recipes contain this ingredients")