Oh I get it and ashamed, thank you for explaining it to me:) so I sould: ini_guess=random.randrange(2) ... for item in list: if item=='h': ... if item ==t': ...
[EMAIL PROTECTED] wrote: > Camellia wrote: > > Well...It' doesn't, have you run it yet? > > Yes it does, and running it reflects that behavior. > > > ini_guess = random.randrange(1) > > list_guess = ['t', 'h'] > > ini_guess = list_guess[ini_guess] > > random.randrange(1) will always return 0, so this will always > initialize ini_guess to 't' > > > for item in list: > > if item == ini_guess: > > correct += 1 > > elif item == 'h': > > ini_guess = 't' > > elif item == 't': > > ini_guess == 'h' > > If item was 't', then correct is incremented and nothing else happens. > ini_guess remains 't'. > If item was 'h', ini_guess will be set to 't'. > > The final "elif item=='t':" branch will never be executed. -- http://mail.python.org/mailman/listinfo/python-list