I have a string of product parts = 'ABCDEF'. Each letter suppose to have a starting value of 100. The user is supposed to add numbers to the specific letter of their choosing and the value of that letter will be updated accordingly. I'm not supposed to use dictionary for this code. I wrote what I roughly know except those with [?]
def updateInventory():
startLevel = 100
partIds = 'ABCDE'
stockLevel = [startLevel] * len(partIds)
productCodes = []
while True:
partIdentifier = input("Enter part identifier or <ENTER> to end: ").upper()
if partIdentifier == '':
break
# partIdentifier must be in partIds
if partIdentifier not in partIds:
print("The part identifier is invalid")
else:
#print the part and its current quantity
print(f"Current stock level for {partIdentifier} = [?]")
while True:
# user tp input how much quantity to add
quantity = int(input("Enter quantity to add: "))
if quantity < 0:
print("The quantity is invalid")
else:
partIds[partIdentifier] += quantity
print(f"Updated stock level for {partIdentifier} = [?]")
break
updateInventory()
Enter part identifier or ENTER to end: T
The part identifier is invalid
Enter part identifier or ENTER to end: E
Current stock level for E = 100
Enter quantity to add: 0
The quantity is invalid
Enter part identifier or ENTER to end: E
Current stock level for E = 100
Enter quantity to add: 25
Updated stock level for E = 125