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?
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)