requests = []
def add_request():
print("\n--- Add Request ---")
while True:
num = input("Request number: ").strip()
if any(r["num"] == num for r in requests):
print("This number already exists, try another.")
else:
break
name = input("Client name: ").strip()
device = input("Device type: ").strip()
problem = input("Problem description: ").strip()
while True:
try:
cost = float(input("Repair cost: "))
if cost < 0:
print("Cost cannot be negative.")
else:
break
except ValueError:
print("Enter a number.")
requests.append({"num": num, "name": name, "device": device,
"problem": problem, "status": "new", "cost": cost})
print("Request added.")
def show_all():
print("\n--- All Requests ---")
if not requests:
print("No requests.")
return
for r in requests:
print(f"#{r['num']} | {r['name']} | {r['device']} | {r['status']} | {r['cost']} rub.")
print(f" Problem: {r['problem']}")
def find_request():
num = input("Request number: ").strip()
for r in requests:
if r["num"] == num:
print(f"#{r['num']} | {r['name']} | {r['status']} | {r['cost']} rub.")
return
print("Not found.")
def change_status():
num = input("Request number: ").strip()
for r in requests:
if r["num"] == num:
new = input("New status (new / in progress / done): ").strip()
if new in ("new", "in progress", "done"):
r["status"] = new
print("Status updated.")
else:
print("Invalid status.")
return
print("Not found.")
def delete_request():
num = input("Request number: ").strip()
for r in requests:
if r["num"] == num:
requests.remove(r)
print("Request deleted.")
return
print("Not found.")
def statistics():
if not requests:
print("No requests.")
return
count = {"new": 0, "in progress": 0, "done": 0}
for r in requests:
count[r["status"]] = count.get(r["status"], 0) + 1
for status, n in count.items():
print(f" {status}: {n}")
while True:
print("\n1. Add 2. Show all 3. Find 4. Change status 5. Delete 6. Stats 0. Exit")
choice = input("Choice: ").strip()
if choice == "1": add_request()
elif choice == "2": show_all()
elif choice == "3": find_request()
elif choice == "4": change_status()
elif choice == "5": delete_request()
elif choice == "6": statistics()
elif choice == "0":
print("Goodbye!")
break
else:
print("Invalid choice.")