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 :
Use this code:
member = str(input("Enter your membership status, y or n: "))
if member == 'y':
print ("You are a member")
elif member == 'n':
print("You need a membership")
- since your
membervariable is having string content, you need to put the values of string in quotes in your if conditionmember == 'y'. - when checking the condition, first you need to start with if instead of elif.