When i comment out the def main() and main() the code runs as expected, but when the function calls go under a main function totalOfItems becomes undefined somehow, does any one know why?
import math
def shoppingTotal(numItem):
totalOfItems = 0
for x in range(numItem):
totalOfItems += int(input('Whats the cost: '))
print(totalOfItems)
return(totalOfItems)
def amountTax(total):
totalTax = (totalOfItems * 1.13) - totalOfItems
print(totalTax)
return(totalTax)
def totalBill(amount, tax):
finalBill = totalTax + totalOfItems
print(finalBill)
return(finalBill)
def greeting():
print('1. Mangoes $5')
print('2. Meat $3')
print('3. Juice $7')
print('4. Banana $2')
def main():
greeting()
numItem = int(input('How many items did you buy: '))
totalOfItems = shoppingTotal(numItem)
total = totalOfItems
totalTax = amountTax(total)
totalBill(amount=totalOfItems,tax=totalTax)
main()