0
我正在製作遊戲。在這個遊戲中,用戶被問到一個問題。如果他得到它的權利,它會進入right_answer列表並進入答案列表。如果他弄錯了,它會進入答案列表。再加上他們得到正確答案的每一個正確的問題。它將成爲8個問題,每一個都是一個功能。這是第一個問題。問題是它沒有打印任何東西。如何將列表返回給函數外的另一個列表
def question_one(answer,right_answer,points):
answer = []
right_answer = []
print "how would you write this question in code so it would print"
answer=raw_input("< ")
#this is if he gets it right
if answer=="""print "how would you write this question in code so it would
print""""":
#this is where the answers are inserted into the lists
right_answer.append(answer)
# this is where the answer goes that they gave
answer.append(answer)
points=points+1
#this is if he gets it wrong
else:
answer.append(answer)
#this is to return the values and the lists for the right answer and the
answer
return answer,right_answer,points
(answer.append(answers),correct_answer.append(correct_answers), points)=question_one(answers,correct_answers,points)
不能分配給'append'呼叫或任何其他功能或方法調用。 – user2357112
你能澄清一點嗎?我很困惑,你在最後一行代碼 – Mangohero1
上試圖找到你的答案字符串是無效的。你想''「」打印「你如何在代碼中編寫這個問題,以便打印\」「」「''或''''print'如何在代碼中編寫這個問題,以便打印出'''''如果你想使用雙引號,你必須跳過最後一個。 – TemporalWolf