Just a quick one

M. Clift noone at here.com
Wed Aug 25 09:06:32 EDT 2004


Hi,

Just a quick one. I'm trying to call [Bob','One'] with this, but I keep
getting 'unhashable'. I've tried various ' " and [ and can't get the thing
to work. Any offers?

Thanks,

M

<code>

from random import *

Name_Number = xrange(int(raw_input("Choose number of Names (1-20)? ")))

state = [None,None]

nextName = {['Bob','One']:['Rita','Sue'],\
              'Rita':['Mary','Sue',['Bob','One']],\
              'Sue':['Rita','Mary',['Bob','One']],\
              'Mary':['Sue','Rita']}

Name_List = []

tmp = choice((['Bob','One'],'Rita','Sue','Mary'))

for x in Name_Number:
    print state
    while tmp in state[0:2]:
        tmp = choice(nextName[Name_List[-1]])
    print tmp, ", ",
    print
    print "Name ",x+1," is ", tmp
    Name_List.append(tmp)
    state[x%2] = tmp

    print Name_List

<code>





More information about the Python-list mailing list