[英]Python syntax error: invalid syntax on string concatenation
我是 python 编码和一个小型聊天机器人项目的新手。 最后一行代码有什么问题? 我不确定。
favanimal = input("What is your favorite animal?")
time.sleep(2)
print(favanimal + ", I like that choice")
time.sleep(2)
print("One more question, this one is extremely important, so choose carefully!")
time.sleep(2)
petname = input("If you had a pet" + favanimal "what would you name it?")
您在最后一行的favanimal
之后缺少一个+
。 所以只要改变它
petname = input("If you had a pet" + favanimal "what would you name it?")
至
petname = input("If you had a pet" + favanimal + "what would you name it?")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.