import string
x = list(string.digits)
random.shuffle(x)
print(int(str(random.choice(list(range(1, 10)))) + ''.join(x[:3])))
How to generate effectively a random number that only contains unique digits in Python?