Answer the question
In order to leave comments, you need to log in
How to get four random numbers in a row?
I'm new to python so I don't know if my version is better
import random
random_number = ''
for x in range(4):
random_number = random_number + str(random.randint(0, 9))
Answer the question
In order to leave comments, you need to log in
Quite. Shorter, but less readable, can be written like this:
import random
random_digits = 3
print(''. join([str(random.randint(0, 9)) for _ in range(random_digits)]))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question