python - I get "undefined variable" from pydev with the code below. Can someone please tell me what's wrong -
this code i've written. i'm beginner @ python , part of first practice. so, problem i'm getting "undefined variable" error dieface1 , dieface2 in last line of code here.
def rolldie(): die1 = [1,2,3,4,5,6] die2 = [1,2,3,4,5,6] dieface1 = int(random.shuffle(die1)) dieface2 = int(random.shuffle(die2)) diefacetotal = dieface1+dieface2 while (userin > pot or userin < 0): userin = (raw_input(" invalid bet, please enter right bet amount")) print "you rolled ", dieface1, "and ", dieface2
random.shuffle()
not return anything. in code, should getting like:
typeerror: int() argument must string or number, not 'nonetype'
simply, random.shuffle(die1)
on own line. isn't needed in case: if want random value list, use random.choice()
:
dieface1 = random.choice(die1)
Comments
Post a Comment