So I have my code which does work as it generated 6 numbers. However, I feel as though a loop of some kind would work better for two reasons.
First - to eliminate the repetitive code as it is written below and, second, to get my desired output as follows 12 24 63 2 55 3 INSTEAD of what is currently happening [12, 24, 63, 2, 55, 3]
Reason being is that information from a statistics pandas dataframe has the output as 12 24 63 2 55 3 without it being in a list and having commas.
rdmFirstNum = (random.randrange(1, 100))
rdmSecondNum = (random.randrange(1, 100))
rdmThirdNum = (random.randrange(1, 100))
rdmFourthNum = (random.randrange(1, 100))
rdmFifthNum = (random.randrange(1, 100))
rdmSixthNum = (random.randrange(1, 50))
rdmNums = [rdmFirstNum, rdmSecondNum, rdmThirdNum, rdmFourthNum, rdmFifthNum, rdmPwrNum]
print (rdmNums)
You should generate your numbers in a loop, a list comprehension works well here:
or possibly two joined comprehensions:
If you then print
rdmNumsyou will get the string representation of a list e.g.:To print a space separated list of numbers, use
mapto convert them to strings andjoin:Output: