-1
def which_prize():
return "Congratulations! You have won a [prize name]!"
if Points ==0 or Points ==50:
print("Congratulations! You have won a [wooden rabbit]!")
elif Points ==0 or Points ==150:
print("Congratulations! You have won a [no prize]!")
elif Points==151 or Points ==180:
print("Congratulations! You have won a [wafer-thin mint]!")
elif Points ==181 or Points ==200:
print("Congratulations! You have won a [penguin]!")
else:
print("Oh dear, no prize this time.")
輸入到which_prize()
將是點數(整數)。函數which_prize()
應返回文本「恭喜!您贏得了[獎品名稱]!」如果他們贏得了獎品並且文字「哦,親愛的,這次沒有獎品」,那麼將包括獎品名稱。如果沒有獎品。像往常一樣,測試你的功能來檢查它是否正確執行。帶分支的代碼
IndentationError: unindent does not match any outer indentation level.
你怎麼能指望任何這些語句後,在函數的第一行,你'return'運行? – khelwood