Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- filename = raw_input("Enter file name> ")
- current_file = open(filename, 'a')
- current_file.write("\n")
- source = []
- cost = []
- combined = [source + cost]
- def start():
- print("To add entry press 1.")
- print("To view entries press 2.")
- print("To amend an entry press 3.")
- print("To close press 4.")
- option = raw_input("Enter option> ")
- if option == "1":
- add()
- elif option == "2":
- viewed()
- # elif option == "3":
- # amend()
- elif option == "4":
- current_file.close()
- exit(0)
- else:
- current_file.close()
- exit(0)
- def add():
- date_entry = raw_input("Enter date(dd/mm/yy), x to cancel or 0 to return> ")
- s = str(date_entry)
- if len(date_entry) > 1:
- current_file.write(s)
- current_file.write("\n")
- place()
- elif date_entry == "0":
- current_file.close()
- start()
- elif date_entry == "x" or "X":
- current_file.close()
- exit(0)
- else:
- start()
- def place():
- pos = raw_input("Enter place of spend, x to cancel or 0 to return> ")
- s = str(pos)
- if len(pos) > 1:
- source.extend(s)
- spend()
- elif pos == "0":
- current_file.close()
- start()
- elif pos == "x" or "X":
- current_file.close()
- exit(0)
- else:
- start()
- def spend():
- amount = raw_input("Enter amount spent, x to cancel or 0 to return> ")
- s = str(amount)
- if amount > 0.01:
- cost.extend(s)
- current_file.write(combined)
- place()
- elif amount == "0":
- start()
- elif amount == "x" or "X":
- current_file.close()
- exit(0)
- else:
- start()
- #def amend():
- # current_file = open(filename, 'r')
- # for lines in current_file:
- # print lines
- # current_file.close()
- def viewed():
- opened = current_file
- for i in opened:
- print i
- start()
- start()
Advertisement
Add Comment
Please, Sign In to add comment