问题在于作业。你用的是双等号
==
指定一个值而不是一个等号
=
.
is_male=input("You are male. True or False?")
if is_male == "True":
is_male = True # This should just be single '='
elif is_male == "False":
is_male = False # This should just be single '='
else:
print("Please enter True or False.")
is_tall=input("You are tall. True or False?")
if is_tall == "True":
is_tall = True # This should just be single '='
elif is_tall == "False":
is_tall = False # This should just be single '='
else:
print("Please enter True or False.")
除此之外,我认为这些行只是错误地再次添加。请把那些拿走-
is_male=True
is_tall=False
最后,你的比较应该是-
if is_male and is_tall:
print("User is male and tall.")
elif is_male and ( not is_tall):
print("User is male and short.")
elif (not is_male) and is_tall: # fix the typo here..
print("User is female and tall.")
else:
print("User is female and short")
第二
elif
你在测试
is_male
再次而不是
is_tall
.