a = input() if a<=3: print("You are a baby") elif a>3 and a<18: print("You are a teenager") else : if 18 >= a and a<60: print("You are an adult") else: if a>=60: print("You are an elder") input() 

Closed due to the fact that off-topic participants 0xdb , Sergey Gornostaev , gil9red , Kromster , andreymal 8 December '18 at 12:48 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - 0xdb, Sergey Gornostaev, gil9red, Kromster, andreymal
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • 3
    Add the full text of the error to the question. - Sergey Gornostaev

2 answers 2

The input() function always returns a string value. You get an error because the conditional operator <= cannot compare the string and the number and therefore produces a TypeError error.

If you want to use a as a number, do this:

 a = int(input()) 
  • Thank!!!!!!!! - Artem Titov
 a = int(input()) if a<=3: print("You are a baby") elif a>3 and a<18: print("You are a teenager") elif a>18 and a <60: print("You are an adult") else: print("You are an elder") 

It seems to work. Python very responsive to snoops