Let’s say I need a 3-digit number, so it would be something like:
>>> random(3)
563
or
>>> random(5)
26748
>> random(2)
56
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use either of
random.randintorrandom.randrange. So to get a random 3-digit number:* Assuming you really meant three digits, rather than "up to three digits".
To use an arbitrary number of digits:
Output: