繁体   English   中英

Python 语法错误:字符串连接的语法无效

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM