我不了解数组或索引

时间:2016-03-09 06:46:06

标签: python arrays indexing

我试图编写可以计算多块土地面积的代码。但是,我不明白数组和索引应该如何工作。

这是代码,但不起作用:

array = int(input('How many lands to process?'))
code = [0]*array
length = [0]*array
width = [0]*array
area = [0]*array2

for index in range(0,array):
    code[index] = str(input('Enter a parcel code for each land.'))
for index in range(0,array):
    length[index] = float(input('Enter the length in feet for each land.'))
for index in range(0,array):
    width[index] = float(input('Enter the width in feet for each land.'))    
    area=0
for index in range(0,array2):
    area[index]=float(length[index]*width[index])
for index in range(0,array2):    
    print(area[index])



for index in range(0,array):    
    print(code[index])

0 个答案:

没有答案