# the fillA function has to be defined here before it is called from the main function def fillA(j, k): print " now we are executing function fillA" global a # this declares variable a as a global variable total = 0 while j < k: a.append(j) total = total + a[j] j = j + 1 print " " return total # the printA function has to be defined here before it is called from the main function def printA(j, k): print " now we are executing function printA" global a # declare as global variable defined in main while j < k: print " ..." + str(a[j]) j = j + 1 print " " # Here is the main function # The main can call other functions that have been previously defined # the variable a[] can be used in the other functions. # The other functions must declare it to be a global variable a = [] # define list a print "Starting from main" print " " start = 0 end = 10 t = fillA(start, end) print "Back in main" print " fillA returned the value: " + str(t) print " " printA(start, end) print "Back to main"