How would you generate a random number string in Python based on the following conditions.
- The string must be between the length of 3 and 7
- The string must only contain numbers from 1-7
- The string must not have spaces
I tried the following for the string output but I am struggling with the conditionals
letters = string.digits
print ( ''.join(random.choice(letters) for i in range(10)) )
The output I received was:=
9432814671
If you could be kind enough to help me out and guide me I would be grateful to you.
Aucun commentaire:
Enregistrer un commentaire