Edit: I saw a post about including brackets to make a list. In this case, where would I insert said brackets? Sorry, newbie.
I have a function to generate combinations of any given number range but I need to print out or list all the possible combinations. Instead I'm getting this:
<generator object combinations at 0x00000175A6796040>
The source code:
def combinations(iterable,r):
pool = tuple(iterable)
n = len(pool)
if r > n:
return
indices = list(range(r))
yield tuple(pool[i] for i in indices)
while True:
for i in reversed(range(r)):
if indices[i] !=i + n - r:
break
else:
return
indices[i] += 1
for j in range(i+1,r):
indices[j] = indices[j-1] + 1
yield tuple(pool[i] for i in indices)
combinations(range(4),5)
I would like a list of all number combinations from 0 to 4 in 5-digit numbers. How do I call the function in a way that allows me to view the actual combinations?