On 23/11/2014 03:55, Rustom Mody wrote:
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!
As I'm hopeless at thinking of good names to me it's always 'lookup'.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
--
https://mail.python.org/mailman/listinfo/python-list