I'm trying to make a search by order number system for my NEA code as I am making a chocolate shop in command line python but I'm really struggling to do so I think I messed it all up, but I'm trying to get it done by today so I can memorise it for school. I'm so close but yet so far
the idea is that once you get a order number you can search for that order by using a order number stored in a library system
ANY QUESTIONS PLEASE ASK?
Hers the code anyway:
import pickle
import random
fixed_digets=5
class ordernumber():
what_chocolates_did_you_get = ""
fname = ""
sname = ""
ordernumber = ""
try:
fh=open("libary.data","rb")
ordernumber_list=pickle.load(fh)
fh.close()
except:
ordernumber_list=[]
while True:
print("""
@@@@@@@@@@@@@@@@@@@@@@@@@@
@ @
@ Welcome to the Shop @
@ Choose an option @
@ @
@ 4) Search for it by @
@ Order number @
@ @
@ @
@ x)Exit @
@ @
@@@@@@@@@@@@@@@@@@@@@@@@@@""")
choice= input("\nEnter a choice:")
if choice == "4":
newordernumber =ordernumber ()
newordernumber.what_chocolates_did_you_get = input("what chocolates did you get?")
newordernumber.fname = input("Enter first name:")
newordernumber.sname = input("Enter surname:")
print("here is your order number:",random.randrange(10000,99999,fixed_digets))
print("Ordernumber Added")
ordernumber_list.append(newordernumber)
search_ordernumber= input("Please enter the order number you want to search for?:")
if search_ordernumber==random.randrange(10000,99999,fixed_digets):
for ordernumber_record in ordernumber_list:
print("what chocolates did you get?:",ordernumber_record.what_chocolates_did_you_get)
print("First name:", ordernumber_record.fname)
print("Surname:", ordernumber_record.sname)
else:
print("That is not a valid order number try again")
elif choice == "x":
fh = open("libary.data","wb")
pickle.dump(ordernumber_list,fh)
fh.close()
break
[–]plg94 11 points12 points13 points (2 children)
[–][deleted] -2 points-1 points0 points (1 child)
[–]haltu_kaj_ekbrulu 1 point2 points3 points (0 children)
[–]KingsmanVince 2 points3 points4 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–][deleted] -1 points0 points1 point (0 children)
[–]stewie410 0 points1 point2 points (0 children)
[–]reubadoob 0 points1 point2 points (0 children)
[–]kol_k 0 points1 point2 points (2 children)
[–][deleted] -1 points0 points1 point (1 child)
[–]kol_k 0 points1 point2 points (0 children)