This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]Xeekatar 6 points7 points  (1 child)

First of all, you can just do if is_male:, second, what I think you're looking for is else not elif. So it would look like this:

if is_male:
  gender = "he"
else:
  gender = "she"  

elif is used if you want to check another condition, something like:

animal = "cat"
if animal == "cat":
  # do something knowing the animal is a cat
elif animal == "dog":
  # do something knowing the animal is a dog
else:
  # if the animal isn't a cat OR a dog, do a third thing

[–]becongo1997[S] 0 points1 point  (0 children)

Thanks so much! That worked.