Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Python Automated Response System Help
#1
Hi there everyone. I am new to python and I just wanted to know how it would be possible to generate different responses within this code depending on what I input.

Basically what I need to happen is when I input "I Lost My License", or "Problem Saving File" into the subject of the email.

I need it to output:

Dear customer1@hotmail.com,
Thank you for contacting our company. You will be contacted via email
to verify your license request.
Thank you,
Company Customer Service

I also need to do this with a few other responses. Would I be doing this with if statements? Please let me know if I'm on the right track at all with my code. Any modifications would help me out a ton and help my understanding with python

Thank you :)


print()
print()

email = input("Enter your Email:")
name = input("Enter your Message Subject:")
name = input("Enter your Message Body:")

Problem_Saving_File = input ("Dear " + email + ", Thank you for contacting our company. Saving a file is done by pressing CTRL-S (Windows) or CMD-S (Mac). Thank you, Company Customer Service")

I_Lost_My_License = input (" Dear " + email + ", Thank you for contacting our company. You will be contacted via email to verify your license request. Thank you, Company Customer Service")

Quote
#2
Any help or recommendations would be really appreciated
Quote
#3
(Oct-08-2019, 11:11 PM)altoon Wrote: Basically what I need to happen is when I input "I Lost My License", or "Problem Saving File" into the subject of the email.

I need it to output:

Dear customer1@hotmail.com,
Thank you for contacting our company. You will be contacted via email
to verify your license request.
Thank you,
Company Customer Service

Hi!

Maybe you could use something like:

# license_01.py
#
 
email1 = input('Please, enter your email:\n')
subject1 = input('Please, enter your Message Subject:\n')
subject1 = subject1.lower()
messageBody1 = input('Please, enter your Message Body:\n')

if subject1 == 'i lost my license':
    print(f'''\nDear customer {email1},

Thank you for contacting our company. You will be contacted via email to verify your license request.

Thank you,

Company Customer Service''')
if subject1 == 'problem saving file':
    print(f'''\nDear customer {email1},

Thank you for contacting our company. Saving a file is done by pressing CTRL-S (Windows) or CMD-S (Mac).

Thank you,

Company Customer Service''')
if subject1 != 'i lost my license' and subject1 != 'problem saving file':
    print(f'Sorry, you should write, word for word, either "I lost my license" or "Problem saving file" on the message subject.')
that produces the following inputs and outputs:
Output:
Please, enter your email: user1@fmail.com Please, enter your Message Subject: I Lost My License Please, enter your Message Body: Hello, blah blah blah ... Dear customer user1@fmail.com, Thank you for contacting our company. You will be contacted via email to verify your license request. Thank you, Company Customer Service
Output:
Please, enter your email: user2@fmail.com Please, enter your Message Subject: Problem Saving File Please, enter your Message Body: Hello, blah blah blah ... Dear customer user2@fmail.com, Thank you for contacting our company. Saving a file is done by pressing CTRL-S (Windows) or CMD-S (Mac). Thank you, Company Customer Service
Output:
Please, enter your email: user3@fmail.com Please, enter your Message Subject: This is a test. Please, enter your Message Body: Hello, blah blah blah ... Sorry, you should write, word for word, either "I lost my license" or "Problem saving file" on the message subject.

Nevertheless, note that on line 6:

subject1 = subject1.lower()
changes all the words in the message subject to lowercase, so it doesn't matter if the customer writes "I lost my license", "I lost My license", "I Lost My License", or other possibilities using the same exact words. The same applies to "Problem saving file". Keep in mind, though, that if the customer doesn't write those exact words, even if it is the United Kingdom's spelling 'licence' instead of the United States' spelling 'license', the program would take it as an invalid entered string in the message subject.

You could, of course, do the necessary changes to take this into consideration, or to apply it to your other possible message subjects.

All the best,
newbieAuggie2019

"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
Quote
#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.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Automated Bet placement redmercury 2 281 Dec-04-2019, 10:53 AM
Last Post: redmercury
Question Difference between Python's os.system and Perl's system command Agile741 13 455 Dec-02-2019, 04:41 PM
Last Post: Agile741
  Script for automated task help darkitecture 2 1,199 Mar-26-2017, 07:02 PM
Last Post: micseydel

Forum Jump:


Users browsing this thread: 1 Guest(s)