Spaces:
Runtime error
Runtime error
| # ========================== | |
| # Complaint Letter Generator | |
| # ========================== | |
| # All templates stored in a Python dictionary | |
| templates = { | |
| "electricity": """ | |
| To: {recipient} | |
| Address: {recipient_address} | |
| From: {sender_name} | |
| CNIC: {cnic} | |
| Phone: {phone} | |
| Address: {sender_address} | |
| Subject: Complaint Regarding {issue} in {area} | |
| Respected Sir/Madam, | |
| I am writing to report that {issue} has been occurring in the area of {area} for the past {duration}. | |
| This issue relates to Account / Meter No: {meter_no}, and has caused repeated inconvenience to the residents. | |
| The disruption has affected daily life, including household activities, work, and studies. | |
| Such irregularities in electricity supply create significant difficulty for the community. | |
| I respectfully request your office to kindly inspect this matter and resolve the issue at the earliest. | |
| Your prompt action will be deeply appreciated. | |
| Sincerely, | |
| {sender_name} | |
| """, | |
| "generic": """ | |
| To: {recipient} | |
| Address: {recipient_address} | |
| From: {sender_name} | |
| CNIC: {cnic} | |
| Phone: {phone} | |
| Address: {sender_address} | |
| Subject: Complaint Regarding {issue} | |
| Respected Sir/Madam, | |
| I wish to formally report the following issue: {issue}. | |
| The problem has been ongoing in the area of {area} for the past {duration}. | |
| The related Account / Meter No (if applicable) is: {meter_no}. | |
| This issue is causing inconvenience to residents and affects daily life. | |
| I respectfully request early resolution of this matter. | |
| Your prompt response will be highly appreciated. | |
| Sincerely, | |
| {sender_name} | |
| """ | |
| } | |
| # ========================== | |
| # User Input Section | |
| # ========================== | |
| print("=== WAPDA Complaint Letter Generator ===") | |
| template_type = input("Enter template type (electricity / generic): ").strip().lower() | |
| issue = input("Enter the issue: ") | |
| area = input("Enter the area: ") | |
| meter_no = input("Enter Account No / Meter No: ") | |
| duration = input("Enter duration of issue: ") | |
| # Sender Info | |
| sender_name = input("Your Name: ") | |
| cnic = input("Your CNIC: ") | |
| phone = input("Your Phone: ") | |
| sender_address = input("Your Address: ") | |
| # Recipient Info | |
| recipient = input("Recipient Name/Designation: ") | |
| recipient_address = input("Recipient Office Address: ") | |
| # ========================== | |
| # Generate Letter | |
| # ========================== | |
| if template_type not in templates: | |
| print("\nInvalid template type! Showing generic letter.\n") | |
| template_type = "generic" | |
| letter = templates[template_type].format( | |
| issue=issue, | |
| area=area, | |
| meter_no=meter_no, | |
| duration=duration, | |
| sender_name=sender_name, | |
| cnic=cnic, | |
| phone=phone, | |
| sender_address=sender_address, | |
| recipient=recipient, | |
| recipient_address=recipient_address | |
| ) | |
| # ========================== | |
| # Output Letter | |
| # ========================== | |
| print("\n======================= Generated Complaint Letter =======================\n") | |
| print(letter) | |
| print("==========================================================================") | |