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')
Answers:
when you compare in python its == not =
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).
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')
when you compare in python its == not =
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).