dimanche 23 août 2020

How to execute code if a variable has a certain value?

I have a problem with my code. The language is python. I am trying to use an if statement to execute some code if a variable has a certain value.

op = 5

if(op = 5):
    print("op is 5!")

Every time i run this program, it gives me syntax error. I have tried doing this instead;

op = 5

if op = 5:
    print("op is 5!")

But it still gives me the error. I am asking this question because i am doing a calculator project and need this.

Thanks, a novice programmer

Aucun commentaire:

Enregistrer un commentaire