You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feat: Added itinerary editing functionality (edit_itinerary(), add_new_flight(), AND add_new_attraction) to main.py and manage_itineraries_py, + tidied up itinerary nesting.
print("Welcome to the Travel Itinerary Planner app!\n")
14
15
print("1. Add a new Itinerary")
15
-
print("2. Edit an existing Itinerary")
16
-
print("3. View existing Itineraries")
17
-
print("4. Delete an Itinerary")
18
-
print("5. Log out\n")
16
+
print("2. Edit an existing Itinerary item")
17
+
print("3. Add a new flight/attraction to an existing Itinerary")
18
+
print("4. View existing Itineraries")
19
+
print("5. Delete an Itinerary/Itinerary item")
20
+
print("6. Log out\n")
19
21
20
22
# Check user_choice was a number
21
23
whileTrue:
22
-
user_choice=input("Please select one of the above options (1-5): ")
24
+
user_choice=input("Please select one of the above options (1-6): ")
23
25
ifuser_choice.isdigit():
24
26
choice=int(user_choice)
25
-
if1<=choice<=5:
27
+
if1<=choice<=6:
26
28
break
27
29
else:
28
-
print("Enter a number between 1-5.")
30
+
print("Enter a number between 1-6.")
29
31
else:
30
-
("Invalid input: Please enter a number between 1-5.")
32
+
print("Invalid input: Please enter a number between 1-6.")
31
33
32
34
# Add a new itinerary
33
35
ifuser_choice=="1":
34
36
print("How exciting! Please provide us information about the trip: \n")
35
37
name=input("Name of the itinerary (please choose a name you will remember for later): ")
36
38
location=input("Location (NA if not applicable): ")
37
-
summary=input("Brief description of trip: ")
39
+
description=input("Brief description of trip: ")
38
40
start_date=input("Start date in DD-MM-YYYY: ")
39
41
end_date=input("End date in DD-MM-YYYY: ")
40
-
flights={}
41
-
attractions={}
42
+
flights=[]
43
+
attractions=[]
42
44
43
45
print("\nNow it is time to add flights!")
44
46
user_flight_choice=input("If you want to skip this step, type SKIP and press 'Enter'. Otherwise, press 'Enter'. ")
45
47
flights_list_done=False
46
48
47
49
ifuser_flight_choice=="SKIP":
48
-
flights={}
50
+
flights=[]
49
51
else:
50
52
whilenotflights_list_done:
51
-
flight_details= {}
52
53
53
54
departure_airport=input("Name of the airport you will depart from: ")
54
55
departure_date=input("Date & time of flight departure (Format: DD-MM-YYYY HH:MM): ")
55
56
arrival_airport=input("Name of the airport you will arrive at: ")
56
57
arrival_date=input("Date & time of flight arrival (Format: DD-MM-YYYY HH:MM): ")
57
58
flight_name=f"{departure_airport} to {arrival_airport}"
58
59
59
-
flight_details.update({
60
+
flights.append({
61
+
"flight name": flight_name,
60
62
"departure airport": departure_airport,
61
63
"departure date": departure_date,
62
64
"arrival airport": arrival_airport,
63
65
"arrival date": arrival_date
64
66
})
65
-
flights[flight_name] =flight_details
66
67
67
68
whileTrue:
68
69
add_another_flight=input("Would you like to add another flight? Type Y (yes) or N (no): ")
@@ -80,23 +81,21 @@ def run_app():
80
81
attractions_list_done=False
81
82
82
83
ifuser_attractions_choice=="SKIP":
83
-
attractions={}
84
+
attractions=[]
84
85
else:
85
86
whilenotattractions_list_done:
86
-
attraction_details= {}
87
87
88
88
attraction_name=input("Name of attraction: ")
89
89
attraction_address=input("Address of attraction: ")
90
90
attraction_summary=input("Short description of attraction: ")
91
-
attraction_type=input("(Optional) Provide some tags that categorise what kind of activity this involves.\nExample of format required: hike, exciting, views\n")
92
-
attraction_tags=attraction_type.split(", ")
91
+
attraction_tags=input("(Optional) Provide some tags that categorise what kind of activity this involves.\nExample of format required: hike, exciting, views\n")
93
92
94
-
attraction_details.update({
93
+
attractions.append({
94
+
"attraction name": attraction_name,
95
95
"address": attraction_address,
96
96
"summary": attraction_summary,
97
97
"tag(s)": attraction_tags
98
98
})
99
-
attractions[attraction_name] =attraction_details
100
99
101
100
whileTrue:
102
101
add_another_attraction=input("Would you like to add another attraction? Type Y or N:")
0 commit comments