在一行中输入列表,输出列表元素的和. 输入格式: 一行中输入列表. 输出格式: 在一行中输出列表元素的和. 输入样例: [3,8,-5] 输出样例: 6 代码: a = eval(input()) total = 0 for i in range(0, len(a)): total = total + a[i] print(total)
转自:http://www.cnblogs.com/futuredo/archive/2012/10/22/2734186.html List handling 1 Creating a list 创建一个列表 Lists can only be built starting from the end and attaching list elements at the beginning. If you use the ++ operator like this 列表只能从尾端开始创建,从头