T
T
Timebird2016-02-29 01:30:33
Python
Timebird, 2016-02-29 01:30:33

How to call the return value of a function?

Goodnight.
Please tell me the reason for the error: "NameError: name 'firstarray' is not defined"
There are such functions:

def getsomething1():
    ...
    return firstarray

def getsomething2():
    ....
    return secondarray

def getsomething3(firstarray, secondarray):
    xlist = []
    for i in firstarray:
        i *= secondarray[0]
        x = sin(i)
        xlist.append(x)
    print(xlist)



getsomething1()
getsomething2()
getsomething3(firstarray, secondarray)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
DevMan, 2016-02-29
@Timebird

you return to void:

firstarray = getsomething1()
secondarray = getsomething2()
getsomething3(firstarray, secondarray)
or
getsomething3(getsomething1(), getsomething2())

D
Dimonchik, 2016-02-29
@dimonchik2013

firstarray in the first function must be declared explicitly, at least in the body, optionally in the parameter

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question