+ 1

help me add while loop question given below.....

hello friends, this is coded by me for kirana store... can anyone tell me where can we insert while loop to continue add more customers at one time. now i can add only 1 customer at a one tome. so please help me thank you reply this way.. continue for c and quite for q(keys for looop) import datetime def gettime(): return datetime.datetime.now() def log(d): if (d==1): name = (input("Enter customer name\n----")) grocerry = str(input("items\n----")) price = (input("enter price\n----")) with open (f"{name}.txt","a",) as name: name.write (str([str(gettime())])+" :- "+grocerry+": \n\t\t\t\t "+str(price)+"\n") print("Noted successfully...") def retrieve(d): if (d==2): name = str(input("Enter customer name\n")) with open (f"{name}.txt") as name: for i in name: print(i,end="") print("CUSTOMER RATION BORROWING MANAGEMENT") print("what do you want?\n 1. Log \n2.Retrieve") d = int(input()) if (d==1): log(d) else: retrieve(d)

28th Jan 2022, 6:57 PM
Sheikh Mohammed Ahmedraza
Sheikh Mohammed Ahmedraza - avatar
1 Resposta
+ 1
Sheikh Mohammed Ahmedraza You would add the while loop at the beginning of your retrieve function before the input. You also don't need to check for (d==1) in your log(d) function, since you already check if it's one before you call it. You also don't need to check if (d==2) in your retrieve, since you're calling it in your else if it's not one. And they don't really serve a purpose inside the function, so no real reason to pass them in as a parameter.
29th Jan 2022, 7:28 AM
Benjamin Rogers
Benjamin Rogers - avatar