'How to check if a user inputted string meets requirements

I'm extremely new to coding/python and I need to check if the user of the program is a member of an organization. This is part of a bigger program but this is what I have so far:

member = str(input("Enter your membership status, y or n: "))
elif member == y:
    print ("You are a member")
elif member == n:
    print("You need a membership")

How do I just check if the user is a member and not print anything and if they're not a member print that they need a membership?



Solution 1:[1]

You can also use lower() method of string so as to eliminate the possibility of case mismatching, like this...

member = input("Enter your membership status, y or n: ")
if member.lower() == 'y':
    print ("You are a member")
elif member.lower() == 'n':
    print("You need a membership")
else:
    print("Invalid Option")

Now it will work even for the block letters of y and n

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MK14