[問題] 計算list的總合公式?
請問python有沒有公式可以計算list內的數字和?
如果沒有,要用def來寫,該怎麼進行?
例如L=[3,3,2,2,1]
sum(L)=11
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 1.168.63.121
→
10/02 20:55, , 1F
10/02 20:55, 1F
→
10/02 20:59, , 2F
10/02 20:59, 2F
推
10/02 21:10, , 3F
10/02 21:10, 3F
推
10/02 21:15, , 4F
10/02 21:15, 4F
推
10/02 21:18, , 5F
10/02 21:18, 5F
推
10/02 21:34, , 6F
10/02 21:34, 6F
→
10/02 21:52, , 7F
10/02 21:52, 7F
→
10/02 21:53, , 8F
10/02 21:53, 8F
推
10/02 21:57, , 9F
10/02 21:57, 9F
推
10/02 22:45, , 10F
10/02 22:45, 10F
推
10/02 23:15, , 11F
10/02 23:15, 11F
推
10/02 23:58, , 12F
10/02 23:58, 12F
→
10/02 23:59, , 13F
10/02 23:59, 13F
推
10/03 08:28, , 14F
10/03 08:28, 14F
推
10/03 08:46, , 15F
10/03 08:46, 15F
推
10/03 15:59, , 16F
10/03 15:59, 16F
推
10/03 18:40, , 17F
10/03 18:40, 17F
推
10/03 23:11, , 18F
10/03 23:11, 18F
推
10/04 13:25, , 19F
10/04 13:25, 19F
→
10/04 22:02, , 20F
10/04 22:02, 20F
推
10/04 22:51, , 21F
10/04 22:51, 21F
→
10/04 23:00, , 22F
10/04 23:00, 22F
推
10/05 09:05, , 23F
10/05 09:05, 23F
推
10/05 10:36, , 24F
10/05 10:36, 24F
推
10/06 00:31, , 25F
10/06 00:31, 25F
推
10/09 10:16, , 26F
10/09 10:16, 26F
推
10/16 13:57, , 27F
10/16 13:57, 27F
推
10/18 07:16, , 28F
10/18 07:16, 28F
Python 近期熱門文章
PTT數位生活區 即時熱門文章