Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #22159

Re: random number

Date 2012-03-26 08:40 +0200
From Michael Poeltl <michael.poeltl@univie.ac.at>
Subject Re: random number
References <CABgq=FyhR+Ldujj3YKRBpVXRVoeoayuXZviUUcNx-gXnFiHLSw@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.980.1332744526.3037.python-list@python.org> (permalink)

Show all headers | View raw


* Nikhil Verma <varma.nikhil22@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

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: random number Michael Poeltl <michael.poeltl@univie.ac.at> - 2012-03-26 08:40 +0200
  Re: random number Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-03-26 07:24 +0000
    Re: random number Grzegorz Staniak <gstaniak@gmail.com> - 2012-03-26 07:50 +0000
      Re: random number Robert Kern <robert.kern@gmail.com> - 2012-03-26 10:36 +0100

csiph-web