Hello i am french student and i work on a first python 3.7 project
My problem is the following
i have create and object "ingredient" with 4 parameter
Now i have to create a list of object "ingredient" with information contain in a file .TXT
i have done the following programm but the list of object isn't generate
here are some sample of my code :
1- My object "ingredient"
Finally we find our problem
i only had to say when it is int type
My problem is the following
i have create and object "ingredient" with 4 parameter
Now i have to create a list of object "ingredient" with information contain in a file .TXT
i have done the following programm but the list of object isn't generate
here are some sample of my code :
1- My object "ingredient"
def __init__(self, nom: str, quantite: int, unite: str, vegetarien: str) -> None:
# Crée un nouvelle ingrédient. pour le nom, quantite, unite, vegetarien
self._nom = nom
self._quantite = quantite
self._unite = unite
self._vegetarien = vegetarien2- "open file txt and create a first list from the file" liste_ingredients = []
with open("stock.txt", "r") as f:
for line in f.readlines():
# print(line)
liste_ingredients.append(line.split(";"))
del liste_ingredients[0]
print(liste_ingredients)3- The part that doesn't work the goal was to generate a list of object in placard list"placard = []
for i in liste_ingredients:
i[0] = ingredient(i[0], i[1], i[2], i[3])
placard.append(i[0])
print(placard)Thanks a lot for your answer and have a good day ;)Finally we find our problem
i only had to say when it is int type
i[0] = ingredient(i[0], int(i[1]), i[2], i[3])
