Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Fruit stand log by Morten BEIT KEA18DK
- from sys import argv
- script, filename = argv
- counter = 0
- promt = "> "
- spend = []
- sale = []
- target = open(filename, 'a')
- def main_menu():
- choice = 0
- print("Fruitmarket Stock software 10.0.1")
- print("Press 1 to add an iten to the inventory")
- print("Press 2 to add an entry for a sale")
- print("Press 3 to see a list of sales and purchases")
- print("Press 4 to exit the program")
- main_menu()
- choice = input("What would you like to do? ")
- while choice!=4:
- if choice==0:
- choice = int(input("What would you like to do? "))
- if choice==1:
- print("What item did you purchase?")
- item = input("Item: ")
- print("Please enter the amount purchased")
- amount = input("Amount: ")
- entry = "Purchase"
- if len(item) >= 8:
- target_formatter = "{0}\t{1}\t\t{2}\n"
- formatted_lines = target_formatter.format(entry, item, amount)
- target.write(formatted_lines)
- choice = 0;
- print("I've added the item to your inventory.")
- print("\n")
- main_menu()
- else:
- target_formatter = "{0}\t{1}\t\t\t{2}\n"
- formatted_lines = target_formatter.format(entry, item, amount)
- target.write(formatted_lines)
- choice = 0;
- print("I've added sale entry to your list")
- print("\n")
- main_menu()
- elif choice==2:
- print("What item did you sell?")
- item = input("Item: ")
- print("How many were sold?")
- amount = input("Amount: ")
- entry = "Sale"
- if len(item) >= 8:
- target_formatter = "{0}\t\t{1}\t\t{2}\n"
- formatted_lines = target_formatter.format(entry, item, amount)
- target.write(formatted_lines)
- choice = 0;
- print("I've added the item to your inventory")
- print("\n")
- main_menu()
- else:
- target_formatter = "{0}\t\t{1}\t\t\t{2}\n"
- formatted_lines = target_formatter.format(entry, item, amount)
- target.write(formatted_lines)
- choice = 0;
- print("I've added the item to your inventory")
- print("\n")
- main_menu()
- elif choice==3:
- print(f"Your current inputs are:")
- target.close()
- my_text = open(filename).read()
- print(my_text, flush=True)
- target = open(filename, 'a')
- choice = 0
- main_menu()
- elif choice==4:
- print("Thank you! Come again.")
- target.close()
- exit()
- else:
- print("Please enter a number between 1 and 4")
- print("\n")
- choice = 0
- main_menu()
Add Comment
Please, Sign In to add comment