【发布时间】:2015-03-04 16:58:29
【问题描述】:
我试着做一个人工智能只是为了看看我能不能,我不能。但我希望它至少可以工作。 这是我的代码:
while True:
if input(":") == "hello":
print("Hello.")
if input(":") == "good bye":
print("Bye!")
if input(":") == "how are you":
print("Good, i don't feel much. You know, I'm an AI.")
如果你运行它,你会发现它不是 AI 会做的。
【问题讨论】:
-
您现在每次都要求输入。相反,尝试执行一次
input(":")并将结果存储在一个变量中,然后针对该变量写入您的ifs。另外,if True:的意义何在? -
对不起,我的代码中有错字,我实际上是真的
标签: if-statement python-3.x input artificial-intelligence