ניסיתי לעשות כמבוקש - נסו לערוך את הקוד שלמעלה, כך שישאל אם זהו יום ההולדת של המשתמש רק אם הוא בן 17. בדקו שהקוד עדיין עובד כמצופה.
הקוד עובד. אך עדין אם מכניסים 17 > no אני מקבל שאני ב18 ומזל טוב
אשמח לדעת איפה הטעות
הקוד לאחר עריכה שלי:
(יש TAB לפני הif - לא יודע למה הוא מעלים אותם פה)
age = int(input('Please enter your age: '))
allowed_to_enter = False
if age >= 18:
allowed_to_enter = True
if age < 17:
print(‘Please wait for the next two years…’)
allowed_to_enter = False
if age == 17:
print(‘plz wait till 12:00 to answer those qustions:’ )
qustion_birthday = input(‘is it your birthday today? [yes/no]:’)
if age == 17 and answer_for_birthday_is_today == 'yes':
print('Happy birthday! You are 18 now.')
age = age + 1
allowed_to_enter = True
if age == 17 and answer_for_birthday_is_today != 'yes':
print('sorry, maybe next time')
allowed_to_enter = False
#אמור למנוע גישה מכל קלט שהוא לא “יאס” לפי הבנתי
if allowed_to_enter:
print(‘Welcome!’)
if not allowed_to_enter:
print(‘Sorry… Byebye’)