Conditions on if statement
Question:
so my code doesnt read the chemistry or physics conditions i’m not sure how im supposed to include it otherwise. Any ideas or tips for this sort of scenario?
print("are you a student at USask, yes or no?")
student: str = str(input(" "))
print("What department are you in?")
dept: str = str(input(" "))
print("How old are you?")
age: int = int(input( ))
while True:
if student == "yes" and (dept == "ICT" or dept == "Physics" or dept == "Chemistry"):
continue
if age >= 19:
print("Access Granted")
break
elif age < 19:
print("Access Denied")
break
else:
print("Access Denied")
break
Answers:
print("are you a student at USask, yes or no?")
student: str = str(input(" "))
print("What department are you in?")
dept: str = str(input(" "))
print("How old are you?")
age: int = int(input( ))
while True:
if student == "yes" + dept == "ICT" or dept == "Physics" or dept == "Chemistry":
if age >= 19:
print("Access Granted")
break
elif age < 19:
print("Access Denied")
break
else:
print("Access Denied")
break
Try this, your continue statement in the first if just restarts the loop and never goes to the following if statements.
so my code doesnt read the chemistry or physics conditions i’m not sure how im supposed to include it otherwise. Any ideas or tips for this sort of scenario?
print("are you a student at USask, yes or no?")
student: str = str(input(" "))
print("What department are you in?")
dept: str = str(input(" "))
print("How old are you?")
age: int = int(input( ))
while True:
if student == "yes" and (dept == "ICT" or dept == "Physics" or dept == "Chemistry"):
continue
if age >= 19:
print("Access Granted")
break
elif age < 19:
print("Access Denied")
break
else:
print("Access Denied")
break
print("are you a student at USask, yes or no?")
student: str = str(input(" "))
print("What department are you in?")
dept: str = str(input(" "))
print("How old are you?")
age: int = int(input( ))
while True:
if student == "yes" + dept == "ICT" or dept == "Physics" or dept == "Chemistry":
if age >= 19:
print("Access Granted")
break
elif age < 19:
print("Access Denied")
break
else:
print("Access Denied")
break
Try this, your continue statement in the first if just restarts the loop and never goes to the following if statements.