I am trying to make a stock list display and editor project. I am trying to let users input what product they have and quantity they have in stock but it isnt saving to the txt file.
Where am I going wrong I am not getting any errors.
def showStock(f):
print(f.read())
userDecide = input("""
To add items to your stock list please type 'ADD'
To remove items from your stock please type 'REMOVE'
To close application type 'CLOSE'
""")
if userDecide.lower() == 'add':
addStock(f)
elif userDecide.lower() == 'remove':
delStock()
elif userDecide.lower() == 'close':
print('Closing...')
exit()
else:
print('Response does not match criteria.')
def addStock(f):
item_add = input("""
Please enter the name of the item you wish to add.
: """)
f.write(item_add+': ')
quantityItem = input("""
Item added, please enter the current quantity for the item.
:
""")
f.write(quantityItem+'\n')
userDecide = input("""
Quantity added. All information has been saved. If you need to;
If you need to add more items type 'ADD'
If you need to delete items type 'REMOVE'
If you would like to exit application type 'CLOSE'
""")
if userDecide.lower() == 'add':
addStock(f)
elif userDecide.lower() == 'remove':
delStock()
elif userDecide.lower() == 'close':
print('Closing...')
exit()
else:
print('Response does not match criteria.')
exit()
with open('CurrentStock.txt', 'w+') as f:
print("""
=====================================================
Welcome to Max's stock project.
=====================================================
Current stock:
""")
showStock(f)
addStock(f)