【发布时间】:2020-01-19 05:09:53
【问题描述】:
这是python 3 我只是用数字做了这个程序,但我不能让它和名字一起工作。 我是这样写的
x=input("write a actor from a famous movie:")
if (x==Matt Damon):
print ("Jason Bourne")
else:
print ("type another actor")
据我了解,这是错误的 == 部分,但我不知道为什么。我的另一个想法是写类似:
MattDamon=Jason Bourne等
但这也不起作用,我觉得我错过了一些小事来完成它。
如果有人能帮助我,我会非常高兴,谢谢!!
【问题讨论】:
-
if x == "Matt Damon"?引用字符串文字 -
欢迎来到 SO。您应该已经发布了错误消息和回溯(cf minimal reproducible example) - 在这种特定情况下并不重要(问题很明显)但大多数时候这些是必需的信息 - “不起作用”是一个完全无用的描述一个问题;-)
-
非常感谢您的时间和回答
标签: python if-statement input