[Tutor] 'number' strings error

Christopher Peet Christopher Peet" <cpeet@point4.com
Fri, 2 Mar 2001 14:54:16 -0800


When I run this I get a 'cannot assign to literal' on the number strings.
But if I take that part out I get a 'cannot add type "int' to string' error
on the password =  part. What am I missing?

I realize I can print after each random.choice but I'd still like to know
how to work it this way.

Thanks,

Christopher Peet
_______________

# random 'password' generator

import random

a = 'a'
b = 'b'
c = 'c'

1 = '1'        #
2 = '2'        # errors on these
3 = '3'        #

l = [a, b, c]
n = [1, 2, 3]

if l:
    l1 = random.choice(l)
if l:
    l2 = random.choice(l)
if n:
    n1 = random.choice(n)
if l:
    l3 = random.choice(l)
if l:
    l4 = random.choice(l)

password = l1 + l2 + n1 + l3 + l4

print password