這裏是我的代碼:「語法錯誤」用我的如果,否則,和艾利芙語句(Python)的
print "Hello, and welcome to the Slightly Interactive Autobiography of Robbie Wood."
print "Lets get started, shall we? What chapter would you like to read first?"
chapter = raw_input("Please type either 'Chapter 1', 'Chapter 2' or 'Chapter 3': ")
if chapter = "Chapter 1":
print "Chapter 1"
print chapter_one
else chapter = "Chapter 2":
print "Chapter 2"
print chapter_two
elif chapter = "Chapter 3":
print "Chapter 3"
print chapter_three
elif:
chapters = raw_input("Please type either 'Chapter 1', 'Chapter 2', or 'Chapter 3': ")
# Variables - Chapters
chapter_one = "text here..."
chapter_two = "text here..."
chapter_three = "text here..."
這裏是從終端確切的錯誤信息:
Last login: Fri Sep 7 17:22:59 on ttys000
Robbies-MacBook-Pro:~ robbiewood$ /var/folders/y6/kx37qgbs34124ztdgb4tphs00000gn/T/Cleanup\ At\ Startup/autobiography-368756862.498.py.command ; exit;
File "/private/var/folders/y6/kx37qgbs34124ztdgb4tphs00000gn/T/Cleanup At Startup/autobiography-368756862.497.py", line 9
else chapter = "Chapter 2":
^
SyntaxError: invalid syntax
logout
[Process completed]
可有人請幫我解決這個問題?我是一名初學者的Python編碼員,我正在爲一個學校項目編寫一個「稍微交互的自傳」。
或許還提到變量'chapter_one','chapter_two','chapter_three'應該被引用之前聲明? – AsheKetchum