python - Simple if statement with modulo operator -


newcomer coding, i've decided go through problemsets on codeforces build experience , understanding. i've decided use python first programming language. i'm stuck on question i'm sure i'm right can't seem understand computer finds i'm wrong.

website link

tl;dr

input

the first (and only) input line contains integer number w (1 ≤ w ≤ 100) — weight of watermelon bought boys.

output

print yes, if boys can divide watermelon 2 parts, each of them weighing number of kilos; , no in opposite case.

i've decided tackle problem using if statement , modulo:

if w % 2 == 0:      print('yes') 

i've run through python shell , every time w print yes , if not have no output. yet when submit code says wrong answer on test 1...

edit: 'only 1 input line' condition mean have put if , else statements on 1 line?

you need add else statement prints no in opposite case:

... else:     print('no') 

with said, if read question says

each of them weighing number of kilos

to 2 pieces, each weighting number of kilos need compute w> 2 , w % 4 == 0 (see comments why):

if w > 2 , w % 4 == 0:      print('yes') else:     print('no') 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -