My first Python program gets an input from the user about his birthday and calculate if he or she is 18+.
My while loop won't continue if the string "check" is equal to true
; it's only working for True
. Why not?
import time
import datetime
check = "Null"
year_born = month_born = day_born = 0
while check != "True":
#or check!="true":
year_born = input("what year were you born?")
month_born = input("what month were you born?")
day_born = input("what day were you born?")
check = raw_input("your birth day is on {0}/{1}/{2}... type 'True' to confirme: ".format(day_born, month_born, year_born))
year_now = int(datetime.date.today().strftime("%Y"))
month_now = int(datetime.date.today().strftime("%m"))
day_now = int(datetime.date.today().strftime("%d"))
if (year_now - 18 > year_born) or (year_now - 18 == year_born and month_born <= month_now and day_born <= day_now):
print("You are 18+. you are allowed to enter")
else:
print("Good bye")
I tried while check != "True" or "true"
and while check != "True" or check != "true"
and while ((check != "True") or (check != "true))
. None of them seem to work; it's just ignoring "true" and "True" and keeps looping.