我无法根据使用代码创建的数字创建列表。
ListA = [5,1,3,8,4]
LengthB = (len(ListA))
obj0 = ListA[0]
obj1 = ListA[1]
obj2 = ListA[2]
obj3 = ListA[3]
obj4 = ListA[4]
obj01 = int(obj0)
obj11 = int(obj1)
obj21 = int(obj2)
obj31 = int(obj3)
obj41 = int(obj4)
obj010 = obj01+obj11
obj110 = obj01+obj11+obj21
obj210 = obj11+obj21+obj31
obj310 = obj21+obj31+obj41
obj410 = obj31+obj41
ListBnum0 = (obj010 / 2)
ListBnum1 = obj110 / 3
ListBnum2 = obj210 / 3
ListBnum3 = obj310/ 3
ListBnum4 = obj410 / 2
print(ListBnum0)
print(ListBnum1)
print(ListBnum2)
print(ListBnum3)
print(ListBnum4)
FinalForm1 = str(ListBnum0)
FinalForm2 = str(ListBnum1)
FinalForm3 = str(ListBnum2)
FinalForm4 = str(ListBnum3)
FinalForm5 = str(ListBnum4)
基本上,该程序采用ListA
数字并计算数字后面的数字的平均值,如果适用的话,数字和后面的数字。我真正的问题是我怎样才能从数字ListBnum(0)
中ListBnum(4)
创建另一个列表?
为什么这会在下面返回错误?
ListB = list[ListBnum0,ListBnum1,ListBnum2,ListBnum3,ListBnum4]