Here is the code I have so far.
value=float(input('Enter a number: '))
value2=float(input('Enter a number: '))
value3=value+value2
value4=float(input('Enter a number: '))
value5=value3-value4
class sweetCurrency:
def __init__(self, value):
self.__value = value
def convertToList(self, value):
cList=[0,1,2,3,4,5,6,7,8,9]
cList[0] = value//10000
cList[1] = (value-cList[0]*10000)//5000
cList[2] = (value-cList[0]*10000-cList[1]*5000)//2000
cList[3] = (value-cList[0]*10000-cList[1]*5000-cList[2]*2000)//1000
cList[4] = (value-cList[0]*10000-cList[1]*5000-cList[2]*2000-cList[3]*1000)//500
cList[5] = (value-cList[0]*10000-cList[1]*5000-cList[2]*2000-cList[3]*1000-cList[4]*500)//100
cList[6] = (value-cList[0]*10000-cList[1]*5000-cList[2]*2000-cList[3]*1000-cList[4]*500-cList[5]*100)//25
cList[7] = (value-cList[0]*10000-cList[1]*5000-cList[2]*2000-cList[3]*1000-cList[4]*500-cList[5]*100-cList[6]*25)//10
cList[8] = (value-cList[0]*10000-cList[1]*5000-cList[2]*2000-cList[3]*1000-cList[4]*500-cList[5]*100-cList[6]*25-cList[7]*10)//5
cList[9] = (value-cList[0]*10000-cList[1]*5000-cList[2]*2000-cList[3]*1000-cList[4]*500-cList[5]*100-cList[6]*25-cList[7]*10-cList[8]*5)
print(cList)
def __str__(self):
print('There are',cList[0],'hundred dollar bills',cList[1],'fifty dollar bills',cList[2],'twenty dollar bills',
cList[3],'ten dollar bills',cList[4],'five dollar bills',cList[5],'one dollar bills',cList[6],'quarters',
cList[7],'dimes',cList[8],'nickels',cList[9],'pennies')
def main():
FirstVal=sweetCurrency(value)
FirstVal.convertToList(value)
print(FirstVal)
SecondVal=sweetCurrency(value3)
SecondVal.convertToList(value3)
print(SecondVal)
ThirdVal=sweetCurrency(value5)
ThirdVal.convertToList(value5)
if value4>value3:
print('Error: cannot be higher than last value')
else:
print(ThirdVal)
main()
When I run the code I get NameError: cList is not defined. Sorry for any formatting issues this is my first time using this site.