lundi 1 juin 2020

Generating a random integer excluding certain values [closed]

I have made simple code to generate a random 7 digit number between 1111111 and 9999997

import random

key = random.randint(1111111, 9999997)

print(key)

I need this number to not contain 0, 8 or 9 as the last digit. It also needs to be divisible by 21. How can I do this?




Aucun commentaire:

Enregistrer un commentaire