串列方法 (2)
本練習屬於課程
Python 入門
練習說明
- 使用
.append()兩次,依次加入泳池小屋和車庫的面積:分別是24.5和15.45。注意,務必要按上面的順序新增。 - 印出
areas。 - 使用
.reverse()方法將areas中元素的順序反轉。 - 再次印出
areas。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Create list areas
areas = [11.25, 18.0, 20.0, 10.75, 9.50]
# Use append twice to add poolhouse and garage size
# Print out areas
# Reverse the orders of the elements in areas
# Print out areas