Python Forum
Python Automated Response System Help
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Automated Response System Help
#4
In order to save repeated typing one can use dictionaries and try...except:

email = 'somebody@somewhere'                                                           
subject = 'I lost my license'                                                          
header = (f'Dear customer {email},\n\n' 
           'Thank you for contacting our company.') 
footer = 'Thank you\n\nCompany customer service'
categories = {'i lost my license': 'You will be contacted via email to verify you license request.\n\n',
              'problem saving file': 'Saving file is done by pressing CTRL-S (Windows} or CMD- (Mac).\n\n'}

try: 
    print(f'{header}{categories[subject.lower()]}{footer}') 
except KeyError: 
    print('Sorry, dada-dada-blah-blah') 
This way one needs to add only key-value pair to categories dictionary for additional subject.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
Python Automated Response System Help - by altoon - Oct-08-2019, 11:11 PM
RE: Python Automated Response System Help - by perfringo - Oct-10-2019, 07:09 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Eliminate entering QR - Whatsapp web automated by selenium akanowhere 1 3,096 Jan-21-2024, 01:12 PM
Last Post: owalahtole
  Question about Creating an Automated Process in Python Supratik1234 0 750 Jan-13-2023, 08:29 PM
Last Post: Supratik1234
  Difference between os.system("clear") and os.system("cls") chmsrohit 7 16,656 Jan-11-2021, 06:30 PM
Last Post: ykumar34
  How to get response data from telegram API call in python KanseiDorifto 0 2,617 Oct-22-2020, 12:23 PM
Last Post: KanseiDorifto
  Creating symbolic matrix automated NMMST 2 2,110 Oct-05-2020, 01:42 AM
Last Post: scidam
  Automated service status for windows Pkhan 2 2,160 Sep-30-2020, 10:30 AM
Last Post: Pkhan
  Python Requests package: Handling xml response soumyarani 1 2,175 Sep-14-2020, 11:41 AM
Last Post: buran
  Python: Automated Script to Read Multiple Files in Respective Matrices Robotguy 7 4,216 Jul-03-2020, 01:34 AM
Last Post: bowlofred
  Automated compile - Multiple Target OS? nogi 5 2,610 Mar-24-2020, 11:44 AM
Last Post: jefsummers
  Automated Bet placement redmercury 2 8,345 Dec-04-2019, 10:53 AM
Last Post: redmercury

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020