random number

Robert Kern robert.kern at gmail.com
Mon Mar 26 05:50:22 EDT 2012


On 3/26/12 10:45 AM, Nikhil Verma wrote:
> Hi
>
> Thanks Michael I want exactly wanted this. Great !!!!
> def random_number(id)
> ...    characters = list(string.ascii_lowercase +string.ascii_uppercase
> +string.digits)
>
> I used this this earlier and tried then by using choice .
> This is great.

Note that the id parameter is not used by the function at all. If you call this 
function multiple times with the same input, you will get different results each 
time. Is that what you want? What role did you expect the id parameter to play?

> On Mon, Mar 26, 2012 at 2:54 PM, Michael Poeltl <michael.poeltl at univie.ac.at
> <mailto:michael.poeltl at univie.ac.at>> wrote:
>     It's still not quite clear to me what role 'id' is playing ... so let's
>     check this one;
>     and Steven, who is maybe more experienced than I am will help us ufrther
>
>      >>> import random, string
>      >>> def random_number(id):
>     ...     characters = list(string.ascii_lowercase +
>     ...                       string.ascii_uppercase +
>     ...                       string.digits)
>     ...     coll_rand = []
>     ...     for i in range(6):
>     ...         random.shuffle(characters)
>     ...         coll_rand.append(characters[0])
>     ...     return ''.join(coll_rand)
>     ...
>      >>> id = 5
>      >>> print (random_number(id))
>     puMHCr
>      >>>

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list