random number

Peter Otten __peter__ at web.de
Mon Mar 26 03:57:39 EDT 2012


Nikhil Verma wrote:

> I want something to achieve like this :-
> 
> def random_number(id): # I am passing it from request
>     # do something
>     return random_number
> 
> Output
> 
> random_number(5)
> AXR670

That's normally not called a number (though it could be base 36 or similar).
 
> One input that is a number in return you are getting 6 digit alphanumeric
> string.
> 
> I tried this
> s = '%06d' % random.randint(0, 999999)
> 
> it gives : '192862' (a string )

Your question is not very clear. Can you give some more information, what 
you want to do with your "random" "number", and how the id argument should 
influence possible results, e. g. can the possible outcomes of 
random_number(x) and random_number(y) overlap for x != y?




More information about the Python-list mailing list