def fruits():
for number, item in enumerate(products_fruits, 1):
print(number, item, end="\n")
def vegetables():
for number, item in enumerate(products_vegetables, 1):
print(number, item, end="\n")
def chancelleries():
for number, item in enumerate(products_chancelleries, 1):
print(number, item, end="\n")
print ("Добро пожаловать в Магазин продуктов!")
print("Выберите себе продукты: ", end='\n')
category = ["Фрукты", "Овощи", "Канцелярия"]
products_fruits = ["Бананы", "Яблоки", "Груши", "Апельсины", "Мандарины"]
products_vegetables = ["Капуста", "Картошка", "Морковь", "Помидоры", "Огурцы"]
products_chancelleries = ["Ручки", "Тетради", "Карандаши", "Фломастреы", "Пластилин"]
shoplist = []
shop = True
while shop:
for number, item in enumerate(category, 1):
print(number, item, end="\n")
print("Если желаете закончить покупки, нажмите 'q'")
takecategory = input("Выберите категорию: ")
if takecategory == "1":
fruits()
fruit = True
while fruit:
print("Если желаете вернуться в Категории, нажмите 'q'")
takefruits = input("Выберите фрукты: ")
if takefruits == "1":
shoplist.append(products_fruits[0])
elif takefruits == "2":
shoplist.append(products_fruits[1])
elif takefruits == "3":
shoplist.append(products_fruits[2])
elif takefruits == "4":
shoplist.append(products_fruits[3])
elif takefruits == "5":
shoplist.append(products_fruits[4])
elif takefruits == "q":
fruit = False
else:
print("Такого фрукта в списке нет!")
print("В вашей корзине" + str(shoplist), end="\n\n")
elif takecategory == "2":
vegetables()
vegetable = True
while vegetable:
print("Если желаете вернуться в Категории, нажмите 'q'")
takevegetables = input("Выберите овощи: ")
if takevegetables == "1":
shoplist.append(products_vegetables[0])
elif takevegetables == "2":
shoplist.append(products_vegetables[1])
elif takevegetables == "3":
shoplist.append(products_vegetables[2])
elif takevegetables == "4":
shoplist.append(products_vegetables[3])
elif takevegetables == "5":
shoplist.append(products_vegetables[4])
elif takevegetables == "q":
vegetable = False
else:
print("Таких овощей в списке нет!")
print("В вашей корзине" + str(shoplist), end="\n\n")
elif takecategory == "3":
chancelleries()
chancellery = True
while chancellery:
print("Если желаете вернуться в Категории, нажмите 'q'")
takechancelleries = input("Выберите канцелярский товар: ")
if takechancelleries == "1":
shoplist.append(products_chancelleries[0])
elif takechancelleries == "2":
shoplist.append(products_chancelleries[1])
elif takechancelleries == "3":
shoplist.append(products_chancelleries[2])
elif takechancelleries == "4":
shoplist.append(products_chancelleries[3])
elif takechancelleries == "5":
shoplist.append(products_chancelleries[4])
elif takechancelleries == "q":
chancellery = False
else:
print("Такого канцелярского товара в списке нет!")
print("В вашей корзине" + str(shoplist), end="\n\n")
elif takecategory == "q":
shop = False
else:
print("Такой Категории в списке нет!")
print("Вы купили: ", shoplist, end="\n\n")
print("Спасибо за покупки!")
Добро пожаловать в Магазин продуктов!
Выберите себе продукты:
1 Фрукты
2 Овощи
3 Канцелярия
Если желаете закончить покупки, нажмите 'q'
Выберите категорию: 1
1 Бананы
2 Яблоки
3 Груши
4 Апельсины
5 Мандарины
Если желаете вернуться в Категории, нажмите 'q'
Выберите фрукты: 1
В вашей корзине['Бананы']
Если желаете вернуться в Категории, нажмите 'q'
Выберите фрукты: 2
В вашей корзине['Бананы', 'Яблоки']
Если желаете вернуться в Категории, нажмите 'q'
Выберите фрукты: q
В вашей корзине['Бананы', 'Яблоки']
Вы купили: ['Бананы', 'Яблоки']
1 Фрукты
2 Овощи
3 Канцелярия
Если желаете закончить покупки, нажмите 'q'
Выберите категорию: q
Вы купили: ['Бананы', 'Яблоки']
Спасибо за покупки!