rejection sampling method. Create a 4 digit random combination from 10 digits and resample if it doesn't match the criteria.
r4=0
while r4 < 1000:
r4=int(''.join(map(str,random.sample(range(10),4))))
noticed that this is essentially the same as @Austin Haskings's answeranswer