This is some of my homework but i am really stuck and can't find any advice online.
def main():
endProgram = 'n'
print()
while endProgram == 'n':
total = 0
totalPlastic = 0
totalMetal= 0
totalGlass = 0
endCount = 'n'
while endCount == 'n':
print()
print('Enter 1 for Plastic')
print('Enter 2 for Metal')
print('Enter 3 for Glass')
option = int(input('Enter now: '))
if option == 1:
totalPlastic = getPlastic(totalPlastic)
elif option == 2:
totalMetal = getMetal(totalMetal)
elif option == 3:
totalGlass = getGlass(totalGlass)
else:
print('You have entered an invalid input')
return main()
endCount = input('Do you want to calculate the total? (y/n): ')
print()
total = calcTotal(totalPlastic, totalMetal, totalGlass)
printNum(total)
break
endProgram = input('Do you want to end the program? (y/n): ')
def getPlastic(totalPlastic):
plasticCount = int(input('Enter the number of Plastic bottles you have: '))
totalPlastic = totalPlastic + plasticCount * .03
return totalPlastic
def getMetal(totalMetal):
metalCount = int(input('Enter the number of Metal cans you have: '))
totalMetal = totalMetal + metalCount * .05
return totalMetal
def getGlass(totalGlass):
glassCount = int(input('Enter the number of Glass bottles you have: '))
totalGlass = (totalGlass + glassCount * .10)
return totalGlass
def calcTotal(totalPlastic, totalMetal, totalGlass):
total = totalPlastic + totalMetal + totalGlass
return total
def printNum(total):
print('Your total recyclable value is $', total)
main()
My problem is I run the code and it works fine for 99% of it. The program will ask any type and amount of bottle, and it totals it correctly too, the issue is that the outer loop never gets asked. After it prints the total it just goes right back to asking what type of bottle you have instead of asking you whether or not you want to end the program. Any help is appreciated thanks.