First, the problem with your existing code is that once you return, the function is over. So, you just return the first value and you're done.
A function can't return a loop, because a loop isn't a kind of value.
A function can return an iterable, which is a value that can be looped over. There are a few ways to do this:
You could use yield, as in most of the other answers, to make your function a generator function, so it returns an iterator over all of the things you yield.
But yielding inside a loop is just a clumsy way of doing yield from, so really, you should just do that:
def looping():
a = [25, 50, 75, 100, 200, 300]
yield from a
for x in looping():
print(x)
You can instead return an iterator directly:
def looping():
a = [25, 50, 75, 100, 200, 300]
return iter(a)
for x in looping():
print(x)
Or, most simply of all: a sequence, like a list, is just as iterable as an iterator. So, if you have a list, just return it:
def looping():
a = [25, 50, 75, 100, 200, 300]
return a
for x in looping():
print(x)
While we're at it, you don't even really need an explicit loop there. You can call a function that hides the loop inside, like join:
print('\n'.join(looping()))
Or you can even splat the iterable directly to print:
print(*looping(), sep='\n')
Although in this case, I think the loop is perfectly reasonable, so if you're happy with it, stick with it.
return xyou can justprint(x)yieldinstead ofreturn(andlist(looping()))