Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I am using a function to call another function. When return the value, I am getting: 'NoneType' object is not subscriptable

I am using a function to call another function. When I run the code, I am getting:

‘NoneType’ object is not subscriptable

How can I get the return value and print them?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

e.g ) I run the code , a = equation 2 , b = 10 , c = 2
This will enter test_2, but I cant print the results from function test_2.

a = input('enter eqution')
b = int(input('enter b'))
c = int(input('enter c'))

y_list = []
x_list = []


def test_1(x , y , z):
    if x == "euqation 1"
        test_2(y,z)

    elif x == "equation 2"
        test_3(y,z)

def test_2(angle , c):
    for i in range(0 , angle , 1):
        y = (i * 3)**c
        y_list.append(y)
        x_list.append(i)        
    return ( y_list , x_list , y )


def test_3(angle , c):
    for i in range(0 , angle , 1):
        y = (i * 5)**c
        y_list.append(y)
        x_list.append(i)        
    return ( y_list , x_list , y )



result  = test_1(a , b , c)
print(result[0])
print(result[1])
print(result[2])

>Solution :

Your test_1 function doesn’t return nothing, it should be:

def test_1(x , y , z):
    if x == "euqation 1"
        return test_2(y,z)

    elif x == "equation 2"
        return test_3(y,z)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading