Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. import os
  2. import sys
  3. import ast
  4. previous_history = os.stat("holiday_info.txt").st_size == 0
  5.  
  6. if previous_history == False:
  7. print("You have used the program previously, do you want to check against your saved data?\nPress Y for yes and N for no")
  8. choice = input("\n")
  9.  
  10. if choice == "Y":
  11. hInfo = open("holiday_info.txt", "r")
  12. pData = open("packing_items.txt", "r")
  13. tData = open("tasks.txt", "r")
  14.  
  15. area = hInfo.read()
  16. packing_items_unparsed = pData.read()
  17. tasks_unparsed = tData.read()
  18.  
  19. packing_items = packing_items_unparsed.strip('][').split(', ')
  20. tasks = tasks_unparsed.strip('][').split(', ')
  21.  
  22. print("Data loaded! Holiday to: " + area + "!")
  23.  
  24. print("Items to pack:\n------------------")
  25.  
  26. i = 0
  27. while i < len(packing_items):
  28. item = packing_items[i][1:-1]
  29.  
  30. print(item)
  31. i += 1
  32.  
  33. i = 0
  34.  
  35. print("\nTasks to complete:\n------------------")
  36.  
  37. while i < len(tasks):
  38. item = tasks[i][1:-1]
  39.  
  40. print(item)
  41. i += 1
  42.  
  43. sys.exit()
  44.  
  45.  
  46.  
  47. else:
  48. destination = input("What's the destination of your holiday? ")
  49. pack_amount = int(input("How many things do you need to pack? "))
  50. task_amount = int(input("How many tasks do you need to complete? "))
  51.  
  52. packing_items = []
  53. tasks = []
  54.  
  55. print("Enter your packing items!")
  56. for i in range(pack_amount):
  57. item = input()
  58. packing_items.append(item)
  59.  
  60. print("Enter your tasks!")
  61. for i in range(task_amount):
  62. item = input()
  63. tasks.append(item)
  64.  
  65. hInfo = open("holiday_info.txt", "w")
  66. pData = open("packing_items.txt", "w")
  67. tData = open("tasks.txt", "w")
  68.  
  69. hInfo.write(destination)
  70. hInfo.close()
  71.  
  72. pData.write(str(packing_items))
  73. pData.close()
  74.  
  75. tData.write(str(tasks))
  76. tData.close()
  77.  
  78. print("Data saved! Program will now exit, to view your data reopen the program!")
  79.  
  80. sys.exit()
  81.  
  82.  
  83.  
  84. destination = input("What's the destination of your holiday? ")
  85. pack_amount = int(input("How many things do you need to pack? "))
  86. task_amount = int(input("How many tasks do you need to complete? "))
  87.  
  88. packing_items = []
  89. tasks = []
  90.  
  91. print("Enter your packing items!")
  92. for i in range(pack_amount):
  93. item = input()
  94. packing_items.append(item)
  95.  
  96. print("Enter your tasks!")
  97. for i in range(task_amount):
  98. item = input()
  99. tasks.append(item)
  100.  
  101. hInfo = open("holiday_info.txt", "w")
  102. pData = open("packing_items.txt", "w")
  103. tData = open("tasks.txt", "w")
  104.  
  105. hInfo.write(destination)
  106. hInfo.close()
  107.  
  108. pData.write(str(packing_items))
  109. pData.close()
  110.  
  111. tData.write(str(tasks))
  112. tData.close()
  113.  
  114. print("Data saved! Program will now exit, to view your data reopen the program!")
  115.  
  116. sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement