0
What is wrong in this code??
number = int(input ("Enter the number")) if number % 2 = 2 : print ("This is an even no.") else: print ("This is an odd no.")
4 Answers
+ 2
Prince
number % 2 == 0
single equal (=) is used to assign value not used to compare values.
and what about 2?
Is it not even number?
0
Please explain concept of 2.
0
As AJ said it should be 0
Why zero?
Do you know what % means??
It calculates the remainder, right.
So if we do:
print(4%2)
then the answer will be zero it means that for any even number the remainder will be zero if we will divide it by 2.
That's why we use:
...
x%2==0:
...