Я вижу вашу проблему и заметил несколько вещей:
- Первая проблема незначительна, но может быть быстро исправлена:
items = input()
Этодолжно быть:
items = int(input())
Поскольку всякий раз, когда мы хотим получить значение из входной функции, мы собираемся получить строковый тип, независимо от того, передаете ли вы через него число.Чтобы исправить это, мы превращаем строку в целое число, помещая перед ней int
Упрощение кода и проблема отступа:
print("what is the inventory number of the item")
inventoryNum = int(input())
Можно упростить до:
inventoryNum = int(input("What is the inventory number of the item: "))
-Кроме того, в конце, так как кажется, что все элементыкоторые не являются частью первых трех условий, связанных с inventoryNum, находятся на первом этаже, вы можете просто использовать оператор else.Вот так:
if(inventoryNum >= 1000 and inventoryNum <= 1999):
print("The item is on the lower level")
elif(inventoryNum == 8005 or inventoryNum == 8000):
print("The item is on the mezzanine")
elif(inventoryNum > 1999 and inventoryNum <= 5000) or (inventoryNum>9000):
print("The item is on the main floor")
else:
print("The item is on the upper level")
Наконец, для того, чтобы цикл while работал, уменьшение значения элемента на 1 должно иметь отступ снаружи, иначе значение будет уменьшаться только на единицу, когда один из операторов elif является путем, по которому он идет:
print("the item is on the upper level")
items = items - 1
Должно быть:
inventoryNum = int(input("What is the inventory number of the item: "))
if(inventoryNum >= 1000 and inventoryNum <= 1999):
print("The item is on the lower level")
elif(inventoryNum == 8005 or inventoryNum == 8000):
print("The item is on the mezzanine")
elif(inventoryNum > 1999 and inventoryNum <= 5000) or (inventoryNum>9000):
print("The item is on the main floor")
else:
print("The item is on the upper level")
#items -= 1 is indented outside of the if/elif/else statement since you want the value of items to decrease after each iteration
items -= 1 #Simpler way of saying items = items - 1, works with + and / as well
print("All items registered. End of program") #Thought that this would be a nice way of notifying the user that they've reached the end of the program
Надеюсь, это поможет.