วันอาทิตย์ที่ 25 ตุลาคม พ.ศ. 2558

Find total number of chairs (in the building)


def setup():
   one = [10, 20, 30, 40, 50]
   two = [60, 50, 40, 30, 20]
   three = [50, 30, 20, 40, 60]
   four = [10, 80, 50, 20, 90]
   a = [one, two, three, four]
   total(a)
 
def total(a):
   i = 0
   total = 0
   while(i < len(a)):
      x = 0
      while(x < len(a[i])):
         total = total + a[i][x]
         x = x +1
      i = i + 1
   print("Total is",total)
 
setup()

ไม่มีความคิดเห็น:

แสดงความคิดเห็น