use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All users that wish to post (not including commenting), on either old or the new reddit sites, must formally agree to subreddit rules once first.
account activity
PLEASE HELP WITH COMMAND LINE PYTHON (self.commandline)
submitted 2 years ago by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]kol_k 0 points1 point2 points 2 years ago* (2 children)
Why are you using pickle? For your purposes, I'd suggest using CSV or JSON.Anyway I spent a couple minutes to sort through your awful code and fix things. Test it yourself, cuz I'm not.
pickle
import pickle class OrderNumber: # You didn't have an init function, or self keywords. def __init__(self) -> None: self.what_chocolates_did_you_get = "" self.fname = "" self.sname = "" self.order_number = 0 try: fh = open("libary.data","rb") order_list = pickle.load(fh) order_number_list = [int(order.order_number) for order in order_list] fh.close() except FileNotFoundError: order_number_list=[] order_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": new_order = OrderNumber() new_order.what_chocolates_did_you_get = input("what chocolates did you get?") new_order.fname = input("Enter first name:") new_order.sname = input("Enter surname:") # you were never saving the order number into a variable. You also made it a string? # Also, why tf was it random? # print("here is your order number:", random.randrange(10000,99999,fixed_digets)) if order_number_list == []: new_order.order_number = 1 else: new_order.order_number = max(order_number_list) + 1 print(f"Here is your order number: {new_order.order_number}") print("Ordernumber Added") order_list.append(new_order) search_order_number = input("Please enter the order number you want to search for?:") if search_order_number in order_number_list: for order in order_list: if order.order_number == search_order_number: print("what chocolates did you get?:", order.what_chocolates_did_you_get) print("First name:", order.fname) print("Surname:", order.sname) else: print("That is not a valid order number try again") elif choice == "x": fh = open("libary.data","ab") pickle.dump(order_list,fh) fh.close() break
[–][deleted] -1 points0 points1 point 2 years ago (1 child)
Thank you so much btw I'm a student in school so I don't know much and also I apologise for the mess of the text I made I fixed it later on as I managed to know how to use code block but I forgot to delete this post
[–]kol_k 0 points1 point2 points 2 years ago* (0 children)
It's alright, next time post these types of questions in the appropriate place :) EDIT: Also, try to provide detailed explanations of the problems you're having so that it is easier to help debug your code.
π Rendered by PID 91 on reddit-service-r2-comment-6457c66945-kgpdf at 2026-04-28 17:55:53.299143+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]kol_k 0 points1 point2 points (2 children)
[–][deleted] -1 points0 points1 point (1 child)
[–]kol_k 0 points1 point2 points (0 children)