Code is here. https://gist.github.com/anonymous/3dfa30bf0c9470200e5bcebce723836e
Can't figure this out for the life of me. All I need is a simple if/elif statement to ask the user if they want to send an email or check their contacts.
Code is here. https://gist.github.com/anonymous/3dfa30bf0c9470200e5bcebce723836e
Can't figure this out for the life of me. All I need is a simple if/elif statement to ask the user if they want to send an email or check their contacts.
 
    
    Put your else part after if condition and try to use 1-tab indentation in your code
import random
import time
import sys
import smtplib
while x==0:
    try:
        ask=str(input("What would you like to do? Send an email, check your contact book, or edit your calendar? "))
        if "email" or "mail" or "send" in ask:
            print ("Please log in to your email ")
            user=str(input("Email "))
            pwd=str(input("Password "))
            content=str(input("Enter your message "))
            sndr=user #this is to prevent email spoofing or fraud
            rcpt=str(input("Enter a recipient "))
            mail = smtplib.SMTP('smtp.gmail.com',587) #or port 465
            mail.ehlo()
            mail.starttls()
            mail.login(user,pwd)
            mail.sendmail(sndr, rcpt, content)
            mail.close()
        elif "check" or "contact" or "book" in ask:
                print ("working")
    except smtplib.SMTPAuthenticationError:
            print ("Login Failed. Please try again")
 
    
    In your code the structure is as follows:
try:
    if:
except:
    elif:
This cannot work, because the elif does not have an associated if.
Imagine if an if could span the except: if an exception occurred before your if, the elif does not have an associated if, which breaks logic.
