random number

Michael Poeltl michael.poeltl at univie.ac.at
Mon Mar 26 08:40:00 CEST 2012


* Nikhil Verma <varma.nikhil22 at gmail.com> [2012-03-26 08:09]:
> Hi All
> 
> How can we generate a 6 digit random number from a given number ?
what about this?

>>> given_number=123456
>>> def rand_given_number(x):
...     s = list(str(x))
...     random.shuffle(s)
...     return int(''.join(s))
... 
>>> print (rand_given_number(given_number))
653421



More information about the Python-list mailing list