python list
菜鸟求救~~~
现在有两个list,
list1=['1.1','2.2','3.3','4.4'],
list2=['5.5','6.6','7.7','8.8']
这两个list里的元素都是字符串,我想实现的结果是得到
list3=[4.4,4.4,4.4,4.4]
即将list2,list1里的字符串变成浮点数后相减得到list3里的浮点数,
然后求list3内所有元素的总和A,并将总和A除以100
请问高手怎么将这些要求用python写出来啊~~
#--------deal with lists-------
def dealList(list1,list2):
list3 = []
sume = 0
for num in range(4):
list2_value = float(list2.pop())
list1_value = float(list1.pop())
mul = list2_value - list1_value
sume += mul
list3.append(mul)
print list3
return sume
#--------main------------------
def main(list1,list2):
result = dealList(list1,list2)
remainder = result/100
print result
print remainder
if __name__ == "__main__":
#--------list define-----------
list1=['侍岁老1.1','2.2','3.3','4.4']
list2=['5.5','6.6','老升雀渗7.7','8.8']
main(list1,list2)