cannot pass a variable from a function

Doug Jordan djordan8 at houston.rr.com
Thu Jun 17 00:46:42 CEST 2004


I am fairly new to Python.  This should be an easy answer but I cannot get
this to work.  The code is listed below.  I know how to do this in C,
Fortran, and VB but it doesn't seem to work the same way here.
I would appreciate any help.

#try this to pass a list to a function and have the function return
#a variable
#this works
list=[1,4,6,9]
def fctn(c):
    for h in c:
        q=h*80
        print q
#function suppose to return variable
def fctn2(c):
    for h in c:
        q=h*80
        return q
def prntfctn(y):
    for j in y:
        print j
fctn(list)
fctn2(list)
prntfctn(q)

I need to be able to return variables from functions so they can be used
globally in the rest of the program I am writing.
Thanks

Doug





More information about the Python-list mailing list