Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import sys
- import ast
- previous_history = os.stat("holiday_info.txt").st_size == 0
- if previous_history == False:
- print("You have used the program previously, do you want to check against your saved data?\nPress Y for yes and N for no")
- choice = input("\n")
- if choice == "Y":
- hInfo = open("holiday_info.txt", "r")
- pData = open("packing_items.txt", "r")
- tData = open("tasks.txt", "r")
- area = hInfo.read()
- packing_items_unparsed = pData.read()
- tasks_unparsed = tData.read()
- packing_items = packing_items_unparsed.strip('][').split(', ')
- tasks = tasks_unparsed.strip('][').split(', ')
- print("Data loaded! Holiday to: " + area + "!")
- print("Items to pack:\n------------------")
- i = 0
- while i < len(packing_items):
- item = packing_items[i][1:-1]
- print(item)
- i += 1
- i = 0
- print("\nTasks to complete:\n------------------")
- while i < len(tasks):
- item = tasks[i][1:-1]
- print(item)
- i += 1
- sys.exit()
- else:
- destination = input("What's the destination of your holiday? ")
- pack_amount = int(input("How many things do you need to pack? "))
- task_amount = int(input("How many tasks do you need to complete? "))
- packing_items = []
- tasks = []
- print("Enter your packing items!")
- for i in range(pack_amount):
- item = input()
- packing_items.append(item)
- print("Enter your tasks!")
- for i in range(task_amount):
- item = input()
- tasks.append(item)
- hInfo = open("holiday_info.txt", "w")
- pData = open("packing_items.txt", "w")
- tData = open("tasks.txt", "w")
- hInfo.write(destination)
- hInfo.close()
- pData.write(str(packing_items))
- pData.close()
- tData.write(str(tasks))
- tData.close()
- print("Data saved! Program will now exit, to view your data reopen the program!")
- sys.exit()
- destination = input("What's the destination of your holiday? ")
- pack_amount = int(input("How many things do you need to pack? "))
- task_amount = int(input("How many tasks do you need to complete? "))
- packing_items = []
- tasks = []
- print("Enter your packing items!")
- for i in range(pack_amount):
- item = input()
- packing_items.append(item)
- print("Enter your tasks!")
- for i in range(task_amount):
- item = input()
- tasks.append(item)
- hInfo = open("holiday_info.txt", "w")
- pData = open("packing_items.txt", "w")
- tData = open("tasks.txt", "w")
- hInfo.write(destination)
- hInfo.close()
- pData.write(str(packing_items))
- pData.close()
- tData.write(str(tasks))
- tData.close()
- print("Data saved! Program will now exit, to view your data reopen the program!")
- sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement