I need to turn my random list of 25 integers into 5 chunks of 5 that go on 5 different lines.
I have found a way to turn the list in to chunks of 5 but I am unsure of how to separate them onto 5 different lines.
import random
def fill(nx, x, y):
lx = []
j = 0
while (j < nx):
r = random.randint(x, y)
if r not in lx:
lx.append(r)
j = j + 1
return lx
def chunks(l, n):
for i in range(0, len(l), n):
yield l[i:i + n]
def display(lx):
lx = list(chunks(lx, 5))
print(lx)
n = 25
a = 10
b = 50
# myList = []
myList = fill(n, a, b)
display(myList)
That is just the code to get the chunks of 5. I know lx.split wouldn't work because it is a list and I can't use \ to split them line by line. So I am unsure of how to get the 5 chunks onto 5 separate lines. Unless I am missing it the difference between mine ( potential duplicate) and the other question is that I have a list of random numbers already generated instead of trying to list out all of the numbers I am turning the 25 I have into chunks separated onto 5 different lines.