if statement giving errors when ran but not in idle

Question:

I making a if statement for my program and when it runs it gives an error. This is my code:

if num1 = num2:
    print('Equal')
Asked By: Joemama

||

Answers:

when you compare in python its == not =

Answered By: Ebrahim Momin

Basically, you’ve mixed up thw two operaters. = is used for assignment(such as x = 5). == is used to compare two values(like comparing x == y).

Answered By: tigerjade003
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.