Guest User

Untitled

a guest
Mar 10th, 2013
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. filename = raw_input("Enter file name> ")
  2. current_file = open(filename, 'a')
  3. current_file.write("\n")
  4. source = []
  5. cost = []
  6. combined = [source + cost]
  7.  
  8. def start():
  9. print("To add entry press 1.")
  10. print("To view entries press 2.")
  11. print("To amend an entry press 3.")
  12. print("To close press 4.")
  13.  
  14. option = raw_input("Enter option> ")
  15. if option == "1":
  16. add()
  17. elif option == "2":
  18. viewed()
  19. # elif option == "3":
  20. # amend()
  21. elif option == "4":
  22. current_file.close()
  23. exit(0)
  24. else:
  25. current_file.close()
  26. exit(0)
  27.  
  28. def add():
  29. date_entry = raw_input("Enter date(dd/mm/yy), x to cancel or 0 to return> ")
  30. s = str(date_entry)
  31. if len(date_entry) > 1:
  32. current_file.write(s)
  33. current_file.write("\n")
  34. place()
  35. elif date_entry == "0":
  36. current_file.close()
  37. start()
  38. elif date_entry == "x" or "X":
  39. current_file.close()
  40. exit(0)
  41. else:
  42. start()
  43.  
  44. def place():
  45. pos = raw_input("Enter place of spend, x to cancel or 0 to return> ")
  46. s = str(pos)
  47. if len(pos) > 1:
  48. source.extend(s)
  49. spend()
  50. elif pos == "0":
  51. current_file.close()
  52. start()
  53. elif pos == "x" or "X":
  54. current_file.close()
  55. exit(0)
  56. else:
  57. start()
  58.  
  59. def spend():
  60. amount = raw_input("Enter amount spent, x to cancel or 0 to return> ")
  61. s = str(amount)
  62. if amount > 0.01:
  63. cost.extend(s)
  64. current_file.write(combined)
  65. place()
  66. elif amount == "0":
  67. start()
  68. elif amount == "x" or "X":
  69. current_file.close()
  70. exit(0)
  71. else:
  72. start()
  73.  
  74. #def amend():
  75. # current_file = open(filename, 'r')
  76. # for lines in current_file:
  77. # print lines
  78. # current_file.close()
  79.  
  80.  
  81. def viewed():
  82. opened = current_file
  83. for i in opened:
  84. print i
  85. start()
  86.  
  87. start()
Advertisement
Add Comment
Please, Sign In to add comment