簡體   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