Python 3 - Problems with date of birth

0

Good evening, the down code in python3 should return a monthly amount according to the client's age, I used the time module to get the client's age when he informed his year of birth, thinking about the possibility of the user informing a year of birth above the current, I put the following return:

"elif idade < 0:
   print('##ERRO## INFORME ANO VALIDO!') "

But it returns the value of $ 50.00 ...

Can anyone help?

    
asked by anonymous 25.11.2017 / 23:34

2 answers

1
  

An observation to make: method used to calculate the age of the person is not correct, as it should make the complete verification with the day and month of the birth.

In your condition, you start by checking if the age is equal to or less than 18.

if idade <= 18:

Where the problem is, you should also check if age is greater than 0.

if idade >= 0 and idade <= 18:
  

See working at repl.it

    
25.11.2017 / 23:43
-1

Line 11 should read:

if(idade >= 0 and idade <= 18):

On line 21:

else:

    
26.11.2017 / 01:17