Problem with "if "condition

i just try this code for age restriction content…but the 1st "if condition is not working.
i solve this problem by using upper method,but now I want to make it a bit critical and I want to
understand how it work.
please help to solve this.

#To watch a age restricted Video content you should be “MALE” and your age should 18 or above
sex=input("enter Your sex:-")
age=int(input("enter your age:-"))
if age>=18 and (sex[0:3]=="male" or sex[0:3]=="MALE"):
print("Requirement is fulfill...Now you can see this movie")
elif age>=18 or (sex[0:3]=="male" or sex[0:3]=="MALE"):
print("To watch the movie,one requirement is not match")
elif not (age>=18 and (sex[0:3]=="male" or sex[0:3]=="MALE")):
print("To watch the movie both requirement is not match")

If you write sex[0:3], it will take indexes (0,1,2) only. And you’re trying to compare it with a 4 character string… so maybe that’s causing the underlying problem, can you please share the error message?

1 Like

Sir,there is no error message,but the output or result did not match with my expectation.
I just want, those who are the male and their age is 18 or above,only they can be able to see the age restricted video.
but those who are the female or bellow 18,they can’t be able to see,and that’s why I want to print messages in every possible condition.
I’m going to share screen shot,you can go through with it.
(I did’t want to solve it by using upper or lower method)
please help me to solve it.
thank you for your kind attention.

Yeah Sir, You are right!
If I used sex[0:4]“male” Instead of sex[0:3]“male”, this work pretty well.
Thank you sir for your help!!!