+ 1
num=20 if num%2=0: print ("number is even") else: if num%2=1: print ("number is odd")
what is the problem ? help!
6 Respostas
+ 3
num=20
if (num % 2 = 0)
print ("number is even")
else if (num % 2 = 1) {
print ("number is odd")
}
else
//anything you would like
That would be the right way.(You have to put something in the if else if else)
+ 2
oops sorry for that
+ 2
According to your code, I think you are trying for even odd checker in Python.
In that case you must maintain indent in if and else loop. Check the Below code:
num=20;
if num%2==0:
print("Number is even");
else:
print("Number is odd");
//Never forget to mention indent after if and else.
+ 1
@Jaime's solution is right but for comparing two integers you need to use == instead of =, so your program will look something like this
num=20
if num%2==0:
print("number is even")
elif num%2==1:
print("number is odd")
+ 1
thanks for helping