samedi 19 septembre 2020

'if' and 'elif' and 'else' in python question [closed]

My Current Code:

age = int(input("Your Age is:"))
if (age <11 or age >60 ):
    print("You are not eligible")
    break

elif (age >=11 and age<=60):
    print("You are eligible")
    continue

elif (age >15 and age<60):
    print('Ticket is $20')

elif (age >=11 and age<=15):
    print("Ticket is $10")

Output:

File "<ipython-input-12-47ead3cda82a>", line 7
    print("You are eligible to watch a football match")
           ^
SyntaxError: 'break' outside loop

What I want to do:

If the age is less than 11 and or greater than 60 it should display You are not eligible and break the loop right there.

But if the age is between 11 and 60 then it should display You are eligible and then next loop starts i.e if age is greater than 15 and less than 60 then it should display Ticket is $20 else age between greater or equal to 11 and less or equal to 15 display Ticket is $15

Aucun commentaire:

Enregistrer un commentaire