def number(n):
x=[]
for i in range (1,n):
if i%2==0:
x=x+[i]
i=i+1
return(n)
In the above code, no error is showing while running, but no value returned
def number(n):
x=[]
for i in range (1,n):
if i%2==0:
x=x+[i]
i=i+1
return(n)
In the above code, no error is showing while running, but no value returned
As already mentioned in the comments section, there are a few things to note:
number(10)
for example.x
instead of n
.i = i+1
is not needed since range()
already returns an iterable, therefore it has to be removedreturn
does not need to be inside parantheses