Advertisement
gleb34783

Untitled

Mar 24th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.12 KB | None | 0 0
  1. def available_products_cash(banknotes_check, vending_machine, money):
  2.     print("available_products_cash.money =", money)
  3.     if money == 0:
  4.         print("You haven't inserted a banknote. Try again")
  5.     else:
  6.         items = []
  7.         for item in range(len(vending_machine[PRICE])):
  8.             if money >= vending_machine[PRICE][item] and vending_machine[QUANTITY][item] > 0:
  9.                 print(f"Number of {vending_machine[NAME][item]} is {item}")
  10.                 items.append(item)
  11.         choice = int(input("Please, input the number of chosen product: "))
  12.         for i in items:
  13.             if choice in items:
  14.                 print(vending_machine[NAME][choice], vending_machine[PRICE][choice], vending_machine[QUANTITY][choice],
  15.                       end=' ')
  16.                 print()
  17.                 vending_machine[QUANTITY][choice] -= 1
  18.                 money -= vending_machine[PRICE][choice]
  19.                 break
  20.             else:
  21.                 print("You don't have enough money. Try to insert more money or buy another product.")
  22.                 break
  23.     return banknotes_check, vending_machine, money
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement