我想写一个文本冒险。起初,它询问一个人是男性还是女性。如果他们输入“男性”,我希望它使用他,他和他的话。如果他们输入“女”,我想它使用的话她,她等我似乎无法分配东西
print ("Is that person male or female?")
gender = input()
if gender == "male":
1 = his
2 = he
3 = him
else:
1 = her
2 = she
3 = her
我想的话显示,当我把在数字例如:
print (2,"went with", 3,)
这应该说"he went with him"
或"she went with her"
,但它不。
Python中的'1','2'和'3'是无效的[标识符](https://docs.python.org/3/reference/lexical_analysis.html#identifiers) – jonrsharpe
“这应该说些什么,但它没有。“这是对语法错误的轻描淡写。无论如何,你还必须将'his'等放在引号中,因为现在它希望找到一个名为'his'的变量,而不是一个字符串。 –