Advertisement
Guest User

Dodavanje Receptra

a guest
Nov 12th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. recipes = []
  2. def add_recipe():
  3. global recipes
  4. recipe = {
  5. "naziv" : "",
  6. "sastojci" : ""
  7. }
  8. recipe["naziv"] = input("Unesite naziv recepta: ")
  9. ingredient = {
  10. "naziv" : "",
  11. "kolicina" : "",
  12. "jedinica mere" : ""
  13. }
  14. list1 = []
  15. while True:
  16. naziv = input("Unesite naziv sastojka:")
  17. if naziv == "kraj":
  18. break
  19. else:
  20. while(naziv == ""):
  21. naziv = input("Unesite naziv sastojka: ")
  22. ingredient["naziv"] = naziv
  23. kolicina = float(input("Unesite kolicinu sastojka: "))
  24. while(kolicina <= 0):
  25. kolicina = float(input("Unesite kolicinu sastojka: "))
  26. ingredient["kolicina"] = kolicina
  27. jedinica_mere = input("Unesite jedinicu mere: ")
  28. while jedinica_mere not in ["kg", "g", "l", "ml"]:
  29. jedinica_mere = input("Unesite jedinicu mere: ")
  30. ingredient["jedinica mere"] = jedinica_mere
  31. print(ingredient)
  32. list1.append(ingredient)
  33. print(list1)
  34. recipe["sastojci"] = list1
  35. recipes.append(recipe)
  36. print(recipes)
  37.  
  38. def print_recipe():
  39. global recipes
  40. naziv = input("Unesite ime recepta koji zelite da se ispise: ")
  41. naziv.lower()
  42. for i in len(recipes):
  43. for value in recipes[i]:
  44. recipe = recipes[i]
  45. if (value.lower == naziv):
  46. print("Naziv: ", recipe[i]["naziv"])
  47. for i in len(recipe[i]["sastojci"]):
  48. print("Sastojci: ")
  49. print(i, ".", recipe[i]["sastojci"]["naziv"], "," ,recipe[i]["sastojci"]["kolicina"], recipe[i]["sastojci"]["jedinica mere"])
  50.  
  51.  
  52. def menu():
  53. while True:
  54. print("1. Dodavanje novog recepta")
  55. print("2. Ispis recepta")
  56. option = int(input("Odaberite opciju: "))
  57. if option == 1:
  58. add_recipe()
  59. elif option == 2:
  60. print_recipe()
  61. else:
  62. print("Uneliste nepostojecu opciju, pokusajte ponovo...")
  63.  
  64. menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement