On Sunday, November 23, 2014 9:06:03 AM UTC+5:30, Seymore4Head wrote: > Now I am trying to add a dictionary, but it is broke too. > > How do I fix: > class RPS: > key={0:"rock", 1:"paper",2:"scissors"}; > def __init__(self): > self.throw=random.randrange(3) > self.key=key[self.throw]
Maybe you want this? class RPS: key ={0:"rock", 1:"paper", 2:"scissors"} def __init__(self): self.throw=random.randrange(3) self.key=RPS.key[self.throw] Whether reusing 'key' like this is a good idea is another matter! -- https://mail.python.org/mailman/listinfo/python-list