Home > Back-end >  Python local variable to global variable
Python local variable to global variable

Time:06-22

I'm trying to write a modular script, with functions

-Function 1 age = input("tell me your age : ")

-Function 2 weight = input("tell me your weight : ")

-Function 3 birthday = input("tell me your birthday : ")

at the end, i want to send a mail outside functions like :

mail_body = age weight birthday

Thanks you for your time !

CodePudding user response:

you could either use the return command at the end of function to deliver the information to where it is called

mail_body = age   weight   birthday
return mail_body

for example if your function is mailinfo() then you can process the info like

mail_body = mailinfo() #after using return command in function

Or you can declare mail_body as a global function at the start of program

mail_body = "placeholder"
global mail_body
  • Related