多行字串
你的食譜縮放專案需要為每道食譜儲存詳細的烹調步驟。這些說明通常會跨越多行,並包含多個步驟。你將練習儲存一個多行字串,內容是義大利麵料理的完整操作指引,讓它在程式碼中更容易閱讀與維護。
本練習屬於課程
Python 入門(開發者向)
練習說明
- 建立一個名為
cooking_instructions的多行字串變數,內容填入註解中所示的三步驟義大利麵烹調流程。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Store the multi-line cooking instructions
# Step 1: Boil water in a large pot
# Step 2: Add pasta and cook for 10 minutes
# Step 3: Drain and serve with sauce
cooking_instructions = ____
print(cooking_instructions)