我正在制作一个项目,并想知道如何使用代码来判断用户是否输入了"男性","女性","男性&# 34;,或者"女性"。
我正在使用Python 3.0
这是我的代码:
import time
def w(t):
if t == t:
time.sleep(t)
print("In the following story, you are a mouse. Please fill out the following information (the story will use this name and gender).")
w(3)
print('\n')
name = input("Your Name:")
w(0.5)
print('\n')
gender = input("Your Gender (Male / Female):")
w(0.5)
print('\n')
input("Press Enter to Begin The Story")
w(1)
print('\n')
print("The Lion and The Mouse")
print("A Short Tale by Aesop")
w(1)
print('\n')
print("Once upon a time in a secluded jungle, there was a mouse.")
w(2)
print('\n')
if gender == ("male" or "Male"):
heorshe = "he"
hisher = "his"
himher = "him"
himselfherself = "himself"
HeShe = "He"
if gender == "female" or "Female":
heorshe = "she"
hisher = "her"
himher = "her"
himselfherself = "herself"
HeShe = "He"
我还希望能够判断用户是否输入了任何信息!请帮忙!
答案 0 :(得分:0)
您可以使用else:
或if not 'male' or not 'Male:'
,然后打印例如'Please enter Male or Female.'