Answer the question
In order to leave comments, you need to log in
How to generate an ID (random number) that is less than the given one, but has the same number of digits in the record?
Greetings. The task is as follows: there is a maximum ID value. It is necessary that the new id be smaller, but always have a certain number of digits in the record. Either 1 less or 2 less. Example of maximum id: 123434131 I understand that the task is not difficult, but I can't come up with a solution that would seem beautiful. Please share your options. Desirable implementation in python. ? Maybe a library function? Thanks in advance.
Answer the question
In order to leave comments, you need to log in
thanks to those who commented and replied. you can use randrange up to max. ID, and if the number is less, fill with zeros from the beginning
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question