Calling a variable from one function to another function in Python

后端 未结 1 1869
感动是毒
感动是毒 2020-12-15 10:51

I\'m writing a program to send an email through python. I have different def\'s that hold the variables that contain the email username and email password etc.. Then I have

相关标签:
1条回答
  • 2020-12-15 11:22

    You would need to return values in your helper functions and call those functions from your main send_email() function, assigning the returned values to variables. Something like this:

    def get_email_address():
        #the code to open up a window that gets the email address
        Email = input
        return Email
    
    def get_email_username():
        #the code to open up a window that gets email username
        Email_Username = input
        return Email_Username
    
    #same for the email recipient and email password
    
    def send_email():
        # variables from the other def's
        email_address = get_email_address()
        email_username = get_email_username()
    
        #code to send email
    
    0 讨论(0)
提交回复
热议问题