MCPcopy Create free account
hub / github.com/geekcomputers/Python / remove

Function remove

Hotel-Management.py:200–257  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

198
199
200def remove():
201 with open("Management.txt") as File:
202 dictionary = json.loads(File.read().replace("'", '"'))
203
204 dict_num = dictionary.get("Room")
205 dict_len = len(dict_num)
206 if dict_len == 0:
207 print("\nThere is no data in our database\n")
208 menu()
209 else:
210 Room = input("\nEnter your Room Number: ")
211
212 listt = dictionary["Room"]
213 index = int(listt.index(Room))
214
215 listt_fname = dictionary.get("First_Name")
216 listt_lname = dictionary.get("Last_Name")
217 listt_phone = dictionary.get("Phone_num")
218 listt_type = dictionary.get("Room_Type")
219 listt_days = dictionary.get("Days")
220 listt_price = dictionary.get("Price")
221 listt_num = dictionary.get("Room")
222
223 del listt_fname[index]
224 del listt_lname[index]
225 del listt_phone[index]
226 del listt_type[index]
227 del listt_days[index]
228 del listt_price[index]
229 del listt_num[index]
230
231 dictionary["First_Name"] = None
232 dictionary["First_Name"] = listt_fname
233
234 dictionary["Last_Name"] = None
235 dictionary["Last_Name"] = listt_lname
236
237 dictionary["Phone_num"] = None
238 dictionary["Phone_num"] = listt_phone
239
240 dictionary["Room_Type"] = None
241 dictionary["Room_Type"] = listt_type
242
243 dictionary["Days"] = None
244 dictionary["Days"] = listt_days
245
246 dictionary["Price"] = None
247 dictionary["Price"] = listt_price
248
249 dictionary["Room"] = None
250 dictionary["Room"] = listt_num
251
252 with open("Management.txt", "w", encoding="utf-8") as file1:
253 file1.write(str(dictionary))
254
255 print("Details has been removed successfully")
256
257 exit_menu()

Callers 1

menuFunction · 0.70

Calls 4

menuFunction · 0.85
exit_menuFunction · 0.85
getMethod · 0.45
indexMethod · 0.45

Tested by

no test coverage detected