Alright, so I made this code:
lst1 = tuple(range(1, 13))
table1 = ""
x = 0
while x < len(lst1):
for y in range(0, 3):
table1 += str(lst1[x]) + "\t"
x += 1
table1 += "\n"
print(table1)
#Output in console is:
1 2 3
4 5 6
7 8 9
10 11 12
I would like to make 2 more tables that display other random numbers i.e.: from 0 to 48 lets say but still only 12 numbers from that range would be outputted in that format. I'm fairly new to python and can't seem to figure it out through the random module.
This is one of the lists with the random numbers:
lst3 = tuple(range(0, 48))
table3 = ""
x = 0
while x < len(lst3):
for y in range(0, 3):
table3 += str(lst3[x]) + "\t"
x += 1
table3 += "\n"
print(random.sample(lst3, 12))
#Output is: (so basically just 12 random numbers from 1 to 47 that don't repeat)
[28, 15, 35, 11, 30, 20, 38, 3, 31, 42, 9, 24]
Aucun commentaire:
Enregistrer un commentaire