In my following code I have the following lines of coding repeated in my code so am trying to insert them inside a function and call them whenever they are needed, but there is an error happening and I don't know why:
list1=[1000,2000,3000,4000,5000]
i=0
c=0.5
n=1000
def func(list1,i,c,n):
x=list1[i]/2
y=x*c
z=n-y
if z<=0:
list1.pop(i)
func(list1,i,c,n)
print('x=',x,'y=',y,'z=',z)
When i try to execute the code I get an error that x or y or z are not defined.