Hi, I'm new to python, programming in general actually. I was wondering if it was possible to return variables from a function? Hmm that probably didn't make sense, i'll give an example. Lets say i had this program:
-
def main ():
-
age = input ('What is your age in years? ')
-
weeksOld = age * 52
-
print 'Wow, you are at least ', weeksOld, ' weeks old!!!'
-
main ()
-
Is it possible to separate the calculation into a function away from main and still have it return the variable for the print statement? I'll try and show you what i mean:
-
def main ():
-
age = input ('What is your age in years? ')
-
weeksOld (age)
-
print 'Wow, you are at least ', wsOld, ' weeks old!!!'
-
-
def weeksOld (years):
-
wsOld = years * 52
-
return wsOld
-
main ()
-
Sorry if that was hard to understand or if the question was rather nooby, as i said i'm new so try not to flame me too much, thanks!