[Tutor] random.choice() problem

Jack Little jacklittlemc at yahoo.com
Sun Jun 23 08:18:35 CEST 2013


I am trying to use random.choice for a text based game. I am using windows 7, 64-bit python. Here is my code:

def lvl2():
    print "COMMANDER: Who should you train with?"
    trn=random.choice(1,2)
    if trn==1:
        lvl2_1()
        print "Squad One!"
    elif trn==2:
        lvl2_2()
        print "Squad Nine!"





Here is my error:

 File "C:\Users\Jack\Desktop\python\skye.py", line 20, in lvl2
    trn=random.choice(1,2)
TypeError: choice() takes exactly 2 arguments (3 given)
>>> 



Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130622/35a77722/attachment-0001.html>


More information about the Tutor mailing list