Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Conditions on if statement

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

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading