Beginner Question - Very Easy I'm Sure...
Jaime Wyant
programmer.py at gmail.com
Thu Mar 24 16:21:59 EST 2005
str() returns a string, it doesn't change rannum which is still a number...
try ->
rannum = str(rannum)
jw
On Thu, 24 Mar 2005 13:13:25 -0800, Todd_Calhoun <anon at anon.com> wrote:
> I'm trying to generate a random number, and then concetate it to a word to
> create a password.
>
> I get the number and assign it to a variable:
>
> +++++++++++++++++++++++++++++
> word = "dog"
>
> import random
> rannum = random.randrange(100,999)
>
> str(rannum)
>
> word + rannum
> +++++++++++++++++++++++++++++
>
> But when I try to concetate the two, I get an error saying:
>
> ++++++++++++++++++++++++++++
> Traceback (most recent call last):
> File "<pyshell#0>", line 1, in -toplevel-
> list[1] + rannum
> TypeError: unsubscriptable object
> ++++++++++++++++++++++++++++
>
> Any suggestions?
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list