python - Confusion about the return value of the built-in function input -


here problem:

you driving little fast, , police officer stops you. write code compute result, encoded int value: 0=no ticket, 1=small ticket, 2=big ticket. if speed 60 or less, result 0. if speed between 61 , 80 inclusive, result 1. if speed 81 or more, result 2. unless birthday on day, speed can 5 higher in cases.

my code:

speed = int(input()); birthday = input();  if (not birthday):     if (speed <= 60):         print(0);     elif (speed >= 61 , speed <= 80):         print(1);     elif (speed >= 81):         print(2); elif (birthday):     if (speed >= 61 , speed <= 65):         print(0);     elif (speed >= 81 , speed <= 85):         print(1); 

and output:

what doing wrong?

when receive input input(), not boolean, assume here, rather string. thus, should checking

if (birthday == "true") 

and

elif (birthday == "false") 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -