I want to return the last value of y , and the appended list. However, the list is not being returned.
It states : name ‘y’ is not defined.
JavaScript
x
21
21
1
y_list = []
2
x_list = []
3
final_list_y = []
4
final_list_x = []
5
6
7
def test_1(angle , c):
8
for i in range(0 , angle , 1):
9
10
y = (i * 3)**c
11
12
final_list_y = y_list.append(y)
13
final_list_x = x_list.append(i)
14
return y_list , x_list , y
15
16
17
test_1(60 , 5)
18
print (fina_list_y)
19
print (final_list_x)
20
print y
21
Advertisement
Answer
Remove y list = []
. it does not mean anything.
JavaScript
1
7
1
return (y_list , x_list , y )
2
3
result = test_1(60 , 5)
4
print(result[0])
5
print(result[1])
6
print(result[2])
7